2016-09-28 59 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'