【问题标题】:Urban airship takeoff error城市飞艇起飞错误
【发布时间】:2014-10-15 08:00:00
【问题描述】:

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

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);
           }
       });
    }
}

【问题讨论】:

  • 尝试在构建路径中添加 .jar 文件。如果这没有帮助,请发布所有代码。
  • 到达 UAirship.takeOff(this, options) 时显示错误;
  • 检查添加的分析器。如果有任何问题,请告诉我..
  • 仍然有问题,然后尝试创建新项目。添加添加库就可以了
  • 抱歉回复晚了请给我灵魂提示它仍然显示错误 PushManager.enablePush();显示 PushManager 类型的方法 enablePush() 未定义

标签: android urbanairship.com


【解决方案1】:

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

要修复它,您需要将 latest android-support-v4.jar 从 API 21 Android SDK 添加到您的项目中。在 Eclipse 中更新您的 Android SDK 后,您可以:

1) 右键单击​​您的项目 2) 选择“安卓工具” 3) 选择“添加支持库...”

清洁、刷新并重试,您应该一切顺利。祝你好运!

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

【讨论】:

    【解决方案2】:

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

    还要检查项目中是否引用了 android-support-v4.jar。 Right click project -&gt; android tools -&gt; Add support library

    assets folder -&gt; 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);
                }
            });
        }
    }
    

    【讨论】:

    • PushManager.enablePush();不工作没有这样的方法它正在播种
    • 我正在使用 urbanairship-lib-5.0.1.jar
    • 我也在使用 GITHUB 上的城市飞艇 PushSample
    • 确保使用最新版本的支持库更新您的 Android SDK。如果您缺少 NotificationManagerCompat 并包含 v4 支持库,那么它已过时。
    【解决方案3】:

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

    1) 通过在 Application 类中设置(如您所做的那样)

    2) 通过添加资产文件夹

    添加所需的 Urban Airship 库文件。

    【讨论】:

      【解决方案4】:
      ****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 
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多