城市飞艇起飞失误

时间:2014-10-15 08:00:00

标签: android urbanairship.com

我在我的项目中使用Urban飞艇,但是当我编写代码时,它会显示此错误,请给我任何解决方案。

10-15 07:57:54.472: E/AndroidRuntime(1427): FATAL EXCEPTION: Thread-105
10-15 07:57:54.472: E/AndroidRuntime(1427): Process: com.urbanairship.push.sample, PID: 1427
10-15 07:57:54.472: E/AndroidRuntime(1427): java.lang.NoClassDefFoundError: android.support.v4.app.NotificationManagerCompat
10-15 07:57:54.472: E/AndroidRuntime(1427):     at com.urbanairship.push.PushManager.<init>(PushManager.java:186)
10-15 07:57:54.472: E/AndroidRuntime(1427):     at com.urbanairship.UAirship.<init>(UAirship.java:107)
10-15 07:57:54.472: E/AndroidRuntime(1427):     at com.urbanairship.UAirship.executeTakeOff(UAirship.java:302)
10-15 07:57:54.472: E/AndroidRuntime(1427):     at com.urbanairship.UAirship.access$000(UAirship.java:54)
10-15 07:57:54.472: E/AndroidRuntime(1427):     at com.urbanairship.UAirship$2.run(UAirship.java:260)
10-15 07:57:54.472: E/AndroidRuntime(1427):     at java.lang.Thread.run(Thread.java:841)

这是我的代码

 extends Application {

    @Override
    public void onCreate() {
        super.onCreate();

        // Optionally, customize your config at runtime:
        //
         AirshipConfigOptions options = new AirshipConfigOptions();
         options.inProduction = false;
         options.developmentAppKey = "******************";
         options.developmentAppSecret = "*******************";

         UAirship.takeOff(this, options);

        UAirship.takeOff(this, new UAirship.OnReadyCallback() {
           @Override
          public void onAirshipReady(UAirship airship) {
              // Perform any airship configurations here

               airship.getPushManager().setPushEnabled(true);
           }
       });
    }
}

4 个答案:

答案 0 :(得分:1)

我也遇到了同样的问题并且弄明白了。事实证明,缺少的类已添加到API 21支持库中。我一直在使用API​​ 19支持库并且收到此错误。

要解决此问题,您需要从API 21 Android SDK将最新 android-support-v4.jar添加到您的项目中。在您更新Android SDK之后,在Eclipse中,您可以:

1)右键单击您的项目 2)选择&#34; Android工具&#34; 3)选择&#34;添加支持库...&#34;

清洁,刷新并再试一次,你应该好好去。祝你好运!

感谢realepinski之前发表的评论,帮助我解决这个问题!

答案 1 :(得分:0)

右键单击包含的jar。和Build path -> add to build path。 确保在项目属性中properties -> java build path -> order and export并检查包含的库。

同时检查android-support-v4.jar是否在项目中引用。 Right click project -> android tools -> Add support library

assets folder -> airshipconfig.properties

中提及您的密钥详情

使用此课程

public class MyApplication extends Application {

    @Override
    public void onCreate() {
        super.onCreate();

        // Optionally, customize your config at runtime:
        //
        // AirshipConfigOptions options = new AirshipConfigOptions();
        // options.inProduction = false;
        // options.developmentAppKey = "Your Development App Key";
        // options.developmentAppSecret "Your Development App Secret";
        //
        // UAirship.takeOff(this, options);

        UAirship.takeOff(this, new UAirship.OnReadyCallback() {
            @Override
            public void onAirshipReady(UAirship airship) {
                // Perform any airship configurations here

                airship.getPushManager().setPushEnabled(true);
            }
        });
    }
}

答案 2 :(得分:0)

凭证可以通过两种方式添加

1)通过在Application类中设置(就像你所做的那样)

2)通过添加资产文件夹

添加所需的Urban Airship库文件。

答案 3 :(得分:0)

****1. Add below code in App****  
public class App extends Application {
 @Override
    public void onCreate() {
        super.onCreate();
        UAirship.takeOff(this, new UAirship.OnReadyCallback() {
            @Override
            public void onAirshipReady(UAirship airship) {
                airship.getPushManager().setUserNotificationsEnabled(true);
            }
        });
}
}

**2. add file in below path:**
app -> assets -> airshipconfig.properties

**3. In airshipconfig.properties write below code:**
developmentAppKey=************    //  development/Staging Key                                                           developmentAppSecret=**************
productionAppKey=*********     //  Production Key          
productionAppSecret=********
inProduction=true 
developmentLogLevel=DEBUG  //LogLevel is "VERBOSE", "DEBUG", "INFO","WARN","ERROR" or "ASSERT" 
productionLogLevel=ERROR 
fcmSenderId=*******  //FCM Sender ID/Firebase project number
notificationIcon=ic_logo_small  
notificationAccentColor=#000000
notificationChannel=customChannel