2016-09-28 76 views
0

我什麼也沒做,但在logcat中有一個「IncompatibleClassChangeError」。我該如何解決這個GCM IncompatibleClassChangeError?

 FATAL EXCEPTION: IntentService[] 
              Process:  com.yorgan.ilknurbalcipc.yorgan, PID: 982 
              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/com.yorgan.ilknurbalcipc.yorgan/files/instant-run/dex/slice-com.google.android.gms-play-services-gcm-8.4.0_8028f35ea877b98f3f5d34335c02399b7cabc31e-classes.dex) 
               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.yorgan.ilknurbalcipc.yorgan.CARDS.GOOGLE_CLOUD_MESSAGING.GCMRegistrationIntentService.registerGCM(GCMRegistrationIntentService.java:62) 
               at com.yorgan.ilknurbalcipc.yorgan.CARDS.GOOGLE_CLOUD_MESSAGING.GCMRegistrationIntentService.onHandleIntent(GCMRegistrationIntentService.java:36) 
               at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:66) 
               at android.os.Handler.dispatchMessage(Handler.java:102) 
               at android.os.Looper.loop(Looper.java:148) 
               at android.os.HandlerThread.run(HandlerThread.java:61) 

而且我編譯SDK版本是24。此外,

 compile 'com.google.android.gms:play-services:8.4.0' 

     classpath 'com.google.gms:google-services:2.0.0-alpha3' 

我,版本不兼容。如果編譯SDK版本爲23,則應用程序有效。在這種情況下,應用程序在API 24設備中不起作用。

回答

0

原因是你有一個老版本的Google Play服務(8.4.0)。使用舊版本的庫編譯項目會導致錯誤(該方法可能不是靜態的)。如果要用更新後的版本(9.4)再次編譯它,我相信問題將消失,不會更改代碼。

0

在應用程序的的build.gradle

compile 'com.google.android.gms:play-services:9.6.0' 

利用這一點,在這個項目的的build.gradle

classpath 'com.google.gms:google-services:3.0.0'