Android gcm IncompatibleClassChangeError

时间:2016-06-07 17:02:41

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

我收到此错误:

  

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中。任务管理器/文件/即时运行/ DEX /切片com.google.android.gms播放服务-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这样的解决方案,但仍然没有用。

任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:0)

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

我建议你尝试firebase-messaging:9.0.1实现更加简单,它是play-services-gcm中可用功能的超集。有关详情,请参阅docs