我什么都没做,但在logcat中有一个" 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 :(得分:0)
原因是您有旧版Google Play服务(8.4.0)。使用旧版本的库编译项目会导致错误(方法可能不是静态的)。如果您使用更新版本(9.4)再次编译它,我相信问题将在没有代码更改的情况下消失。
答案 1 :(得分:0)
在你的应用的build.gradle中使用它
compile 'com.google.android.gms:play-services:9.6.0'
这是你项目的build.gradle
classpath 'com.google.gms:google-services:3.0.0'