Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
157 views
in Technique[技术] by (71.8m points)

urbanairship.com - Android UrbanAirship Crash in takeOff

Hello I hope someone can help me here.

I′m working on an application which uses UrbanAirship to receive PushNotifications.

My Problem is that, since this morning, my app crashes when initializing UrbanAirship with takeOff.

I′m using Android Studio v2.1.1(stable) and updated my Build and Platform-Tools to use the most current version(s). After the crash occurred I tested if it is caused by the new Tools by using an older Version of these Tools and different Android Studio versions (2.0, 1.3 and 1.5). So I′m sure that should not be the Problem.

Here is the Code I′m using and the Stack Trace from my LogCat:

UAirship.takeOff(this, Config.getOptions(), mAirshipReadyCallback);

getOptions returns the following:

public static AirshipConfigOptions getOptions() {
    return new AirshipConfigOptions.Builder()
        .setDevelopmentAppKey("Key")
        .setDevelopmentAppSecret("Secret")
        .setProductionAppKey("Key")
        .setProductionAppSecret("Secret")
        .setInProduction(!BuildConfig.DEBUG)
        .setGcmSender("Sender")
        .setProductionLogLevel(3).build();
}

And my Callback is the following:

private UAirship.OnReadyCallback mAirshipReadyCallback = new UAirship.OnReadyCallback() {
        @Override
        public void onAirshipReady(UAirship uAirship) {
            DefaultNotificationFactory notificationFactory;
            notificationFactory = new DefaultNotificationFactory(getApplicationContext());

            notificationFactory.setSmallIconId(R.drawable.ic_push);
            notificationFactory.setLargeIcon(R.drawable.ic_launcher);
            try {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                    notificationFactory.setColor(getColor(R.color.main_list_item_text_enabled));
                } else {
                    notificationFactory.setColor(getResources().getColor(R.color.main_list_item_text_enabled));
                }
            } catch (Resources.NotFoundException ex) {
                Timber.e(ex.getCause(), ex.getMessage());
                notificationFactory.setColor(Color.parseColor("0e457e"));
            }

            // Enable user notifications
            Timber.i("Enable Airship!");
            Timber.i("UAirship ChannelId: " + UAirship.shared().getPushManager().getChannelId());
            uAirship.getPushManager().setNotificationFactory(notificationFactory);
            uAirship.getPushManager().setUserNotificationsEnabled(true);
        }
    };

Finally the StackTrace:

java.lang.IncompatibleClassChangeError: The method 'java.io.File android.support.v4.content.ContextCompat.getNoBackupFilesDir(android.content.Context)' was expected to be of type virtual but instead was found to be of type direct (declaration of 'java.lang.reflect.ArtMethod' appears in /system/framework/core-libart.jar)
at com.google.android.gms.iid.zzd.zzeb(Unknown Source)
at com.google.android.gms.iid.zzd.<init>(Unknown Source)
at com.google.android.gms.iid.zzd.<init>(Unknown Source)
at com.google.android.gms.iid.InstanceID.zza(Unknown Source)
at com.google.android.gms.iid.InstanceID.getInstance(Unknown Source)
at com.urbanairship.push.GcmRegistrar.register(GcmRegistrar.java:62)
at com.urbanairship.push.ChannelServiceDelegate.onUpdatePushRegistration(ChannelServiceDelegate.java:174)
at com.urbanairship.push.ChannelServiceDelegate.onHandleIntent(ChannelServiceDelegate.java:110)
at com.urbanairship.BaseIntentService.onHandleIntent(BaseIntentService.java:103)
at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.os.HandlerThread.run(HandlerThread.java:61)

Yesterday everything worked fine and I did not update any libraries I′m using.

Thank you in advance, greetings :)

Edit

Here are my gradle dependencies:

dependencies {

compile fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
repositories {
    mavenCentral()

    flatDir {
        dirs 'libs'
    }

    maven { url 'https://repo.commonsware.com.s3.amazonaws.com' }
    maven { url 'https://urbanairship.bintray.com/android' }
    maven { url 'https://download.01.org/crosswalk/releases/crosswalk/android/maven2' }
}

    compile('com.urbanairship.android:urbanairship-sdk:7.1.3') {
    exclude group: 'com.google.android.support', module: 'support-v4'
    exclude group: 'com.google.android.gms', module: 'play-services-gcm'
        transitive = true
}

compile('de.keyboardsurfer.android.widget:crouton:1.8.5@aar') {
    exclude group: 'com.google.android.support', module: 'support-v4'
    transitive = true
}

compile('com.facebook.android:facebook-android-sdk:4.8.1') {
    exclude group: 'com.google.android.support', module: 'support-v4'
}
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:support-v4:23.3.0'
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.squareup.retrofit:retrofit:2.0.0-beta2'
compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2'
compile 'com.squareup.okhttp:okhttp:2.5.0'
compile 'com.squareup.okhttp:logging-interceptor:2.6.0'
compile 'com.google.code.gson:gson:2.4'
compile 'com.jakewharton:butterknife:5.1.1'
compile 'com.jakewharton.timber:timber:4.1.1'
compile 'commons-io:commons-io:2.4'
compile 'org.apache.commons:commons-lang3:3.4'
compile 'com.google.android.gms:play-services-analytics:8.4.0'
compile 'com.google.android.gms:play-services-gcm:8.4.0'
compile 'com.google.android.gms:play-services-ads:8.4.0'
compile('com.crashlytics.sdk.android:crashlytics:2.5.2@aar') {
    transitive = true;
}

compile 'org.xwalk:xwalk_core_library:16.45.421.19'
compile 'com.amplitude:android-sdk:2.5.0'

}

Edit 2

I also tried to use the UrbanAirship-SDK Version 6.4.1 without excluding google.gms and the android support libraries, without any effect.

Furthermore I updated every possible dependency inside my gradle use the newest version (just the changed):

compile'com.urbanairship.android:urbanairship-sdk:7.1.3'
compile 'com.google.android.gms:play-services:9.0.0'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:support-v4:23.4.0'

still no change

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

As @ralepinski pointed out. The sample app of UA was working like expected. So I dug deeper into the usage of libraries and gradle and found out, that this Issue was caused by the internal usage of

'com.android.support:support-v4:23.4.0'
'com.android.support:appcompat-v7:23.4.0'

Some of the used plugins use these libraries as well and the conflict was in the usage of different versions of these libraries. I solved this issue by using the force command inside the gradle (see below):

configurations.all {
    resolutionStrategy {
        force 'com.android.support:design:23.4.0'
        force 'com.android.support:support-v4:23.4.0'
        force 'com.android.support:appcompat-v7:23.4.0'
    }
}

I′d like to thank you all for your help and I upvotet @ralepinskis answer which gave the hint to look at the sample project. I do not have enough reputation now but when I have the upvote should be added automatically.

:)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...