Android UrbanAirship在起飞时坠毁 [英] Android UrbanAirship Crash in takeOff
问题描述
你好,我希望有人能在这里为我提供帮助.
Hello I hope someone can help me here.
我正在开发一个使用UrbanAirship接收 PushNotifications
的应用程序.
I´m working on an application which uses UrbanAirship to receive PushNotifications
.
我的问题是,从今天早上开始,使用起飞起飞初始化UrbanAirship时,我的应用程序崩溃了.
My Problem is that, since this morning, my app crashes when initializing UrbanAirship with takeOff.
我正在使用Android Studio v2.1.1(稳定版),并更新了Build和Platform-Tools以使用最新版本.发生崩溃后,我使用这些工具的较旧版本以及其他Android Studio版本(2.0、1.3和1.5)测试了它是否是由新工具引起的.因此,我确定那应该不是问题.
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.
这是我正在使用的代码以及LogCat中的堆栈跟踪:
Here is the Code I´m using and the Stack Trace from my LogCat:
UAirship.takeOff(this, Config.getOptions(), mAirshipReadyCallback);
getOptions返回以下内容:
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();
}
我的回叫如下:
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);
}
};
最后 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 :)
修改
这是我的gradle依赖项:
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'
}
编辑2
我还尝试使用UrbanAirship-SDK版本6.4.1,但不排除google.gms和android支持库,没有任何效果.
I also tried to use the UrbanAirship-SDK Version 6.4.1 without excluding google.gms and the android support libraries, without any effect.
此外,我使用最新版本(只是更改了)更新了gradle中所有可能的依赖项:
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'
仍然没有变化
推荐答案
@ralepinski指出.UA的示例应用程序运行正常.因此,我更深入地研究了库和gradle的用法,发现此问题是由内部使用
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'
一些使用过的插件也使用这些库,而冲突之处在于使用这些库的不同版本.我通过在gradle中使用 force
命令解决了这个问题(见下文):
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'
}
}
我要感谢大家的帮助,我upvotet @ralepinskis的回答给出了看一下示例项目的提示.我现在没有足够的声誉,但是当我有赞誉时,应该自动添加.
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.
:)
这篇关于Android UrbanAirship在起飞时坠毁的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!