其他分享
首页 > 其他分享> > android – Urban Airship在起飞时坠毁.非法论证例外

android – Urban Airship在起飞时坠毁.非法论证例外

作者:互联网

我的代码在Applicaion.onCreate中.该应用程序崩溃在UAirship.takeoff(这,选项);请帮忙.

public class LiveVideoApplication extends Application {
    @Override
    public void onCreate() {

        super.onCreate();

        AirshipConfigOptions options = AirshipConfigOptions.loadDefaultOptions(this);

        // Optionally, customize your config at runtime:
        //
        options.inProduction = false;
        options.developmentAppKey = "key.. ";
        options.developmentAppSecret = "secret..";

        UAirship.takeOff(this, options);
        PushManager.shared().setIntentReceiver(IntentReceiver.class);
        Logger.logLevel = Log.VERBOSE;

        //use CustomPushNotificationBuilder to specify a custom layout
        CustomPushNotificationBuilder nb = new CustomPushNotificationBuilder();

        nb.statusBarIconDrawableId = R.drawable.icon_small;//custom status bar icon
//
        nb.layout = R.layout.notification;
        nb.layoutIconDrawableId = R.drawable.icon;//custom layout icon
        nb.layoutIconId = R.id.icon;
        nb.layoutSubjectId = R.id.subject;
        nb.layoutMessageId = R.id.message;

        // customize the sound played when a push is received
        nb.soundUri = Uri.parse("android.resource://"+this.getPackageName()+"/" +R.raw.cat);

        PushManager.shared().setNotificationBuilder(nb);
        PushManager.shared().setIntentReceiver(IntentReceiver.class);

    }
}

异常日志:

03-15 00:25:37.106: E/AndroidRuntime(2920): FATAL EXCEPTION: main
03-15 00:25:37.106: E/AndroidRuntime(2920): java.lang.RuntimeException: Unable to create application com.LiveVideoApplication: java.lang.IllegalArgumentException: Application configuration is invalid.
03-15 00:25:37.106: E/AndroidRuntime(2920):     at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3275)
03-15 00:25:37.106: E/AndroidRuntime(2920):     at android.app.ActivityThread.access$2200(ActivityThread.java:117)
03-15 00:25:37.106: E/AndroidRuntime(2920):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:969)
03-15 00:25:37.106: E/AndroidRuntime(2920):     at android.os.Handler.dispatchMessage(Handler.java:99)
03-15 00:25:37.106: E/AndroidRuntime(2920):     at android.os.Looper.loop(Looper.java:123)
03-15 00:25:37.106: E/AndroidRuntime(2920):     at android.app.ActivityThread.main(ActivityThread.java:3683)
03-15 00:25:37.106: E/AndroidRuntime(2920):     at java.lang.reflect.Method.invokeNative(Native Method)
03-15 00:25:37.106: E/AndroidRuntime(2920):     at java.lang.reflect.Method.invoke(Method.java:507)
03-15 00:25:37.106: E/AndroidRuntime(2920):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
03-15 00:25:37.106: E/AndroidRuntime(2920):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
03-15 00:25:37.106: E/AndroidRuntime(2920):     at dalvik.system.NativeStart.main(Native Method)
03-15 00:25:37.106: E/AndroidRuntime(2920): Caused by: java.lang.IllegalArgumentException: Application configuration is invalid.
03-15 00:25:37.106: E/AndroidRuntime(2920):     at com.urbanairship.UAirship.takeOff(Unknown Source)
03-15 00:25:37.106: E/AndroidRuntime(2920):     at com.LiveVideoApplication.onCreate(LiveVideoApplication.java:27)
03-15 00:25:37.106: E/AndroidRuntime(2920):     at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:969)
03-15 00:25:37.106: E/AndroidRuntime(2920):     at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3272)

解决方法:

我也遇到过这个问题,我解决了.我建议您确保在UrbanAirship上使用与您的应用程序相同的应用程序包创建了一个应用程序.并确保您的密钥和秘密是正确的.

当developmentAppKey和developmentAppSecret错误时抛出IllegalArgumentException.或者密钥和密钥是正确的,但您的远程Urban Airship测试应用程序具有不同的Applicaion包集.

标签:android,push-notification,urbanairship-com
来源: https://codeday.me/bug/20190716/1481266.html