2016-06-07 43 views
0

即時得到這個錯誤:的Android GCM IncompatibleClassChangeError

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 'com.google.android.gms.iid.zzd' appears in /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:[email protected]') { 
    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:[email protected]' 
compile 'com.android.support:recyclerview-v7:+' 
} 

我試圖像this one但還是有些解決方案沒有工作。

任何幫助將不勝感激。

+0

看起來你使用的是play-services:8.1.0,你應該使用9.0.1,你也應該使用特定的播放服務庫,例如:play-services-gcm而不僅僅是播放服務。 –

+0

謝謝!這解決了我的問題,您應該將此評論作爲答案,以便我可以將其標記爲已解決。 – Alexis

回答

0

看起來你使用的是play-services:8.1.0,你應該使用9.0.1,你也應該使用特定的播放服務庫,例如:play-services-gcm而不僅僅是play-services。

我建議你嘗試firebase-messaging:9.0.1實現要簡單得多,它是play-services-gcm中可用功能的超集。有關更多信息,請參閱docs