【问题标题】:Android gcm IncompatibleClassChangeErrorAndroid gcm IncompatibleClassChangeError
【发布时间】:2016-06-07 17:02:40
【问题描述】:

我收到此错误:

java.lang.IncompatibleClassChangeError:方法 'java.io.File android.support.v4.content.ContextCompat.getNoBackupFilesDir(android.content.Context)' 应为虚拟类型,但被发现为直接输入(“com.google.android.gms.iid.zzd”的声明出现在 /data/data/cl.rpro.vendormobile.taskmanager/files/instant-run/dex/slice-com.google.android.gms -play-services-gcm-8.1.0_35df9c24e83b197f349f916cbeab1f3731d6d9dd-classes.dex)

在这一行:

if (checkPlayServices()) {
    // Start IntentService to register this application with GCM.
    Intent intent = new Intent(this, RPRORegistrationIntentService.class);//-> this one
    startService(intent);
}

这是我的依赖:

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
//compile 'com.loopj.android:android-async-http:1.4.6'
compile 'com.squareup.picasso:picasso:2.4.0'
//compile 'io.realm:realm-android:0.79.0'
compile files('libs/mpandroidchartlibrary1_7_4.jar')
compile files('libs/java-json.jar')
compile 'com.android.support:support-v13:21.0.3'
compile 'com.android.support:appcompat-v7:21.0.2'
//compile 'com.google.android.gms:play-services:6.5.87'
//compile 'com.android.support:support-v4:21.0.3'
compile 'com.pkmmte.view:circularimageview:1.1'
compile 'net.simonvt.menudrawer:menudrawer:3.0.6'
compile('com.crashlytics.sdk.android:crashlytics:2.2.0@aar') {
    transitive = true;
}
compile "com.google.android.gms:play-services:8.1.0"
compile 'com.astuetz:pagerslidingtabstrip:1.0.1'
compile 'com.github.aakira:expandable-layout:1.4.1@aar'
compile 'com.android.support:recyclerview-v7:+'
}

我尝试了一些解决方案,例如this one,但仍然没有用。

任何帮助将不胜感激。

【问题讨论】:

  • 看起来您正在使用 play-services:8.1.0,您应该使用 9.0.1,还应该使用特定的播放服务库,例如:play-services-gcm 而不是仅仅播放-服务。
  • 谢谢!这解决了我的问题,您应该将此评论作为答案,以便我可以将其标记为已解决。

标签: android push-notification google-cloud-messaging


【解决方案1】:

看起来您正在使用 play-services:8.1.0,您应该使用 9.0.1,还应该使用特定的播放服务库,例如:play-services-gcm 而不仅仅是播放服务。

我建议你试试 firebase-messaging:9.0.1,它的实现要简单得多,它是 play-services-gcm 中可用功能的超集。请参阅docs 了解更多信息。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-21
    • 1970-01-01
    • 2016-04-07
    相关资源
    最近更新 更多