在执行时出错 - InstanceID instanceID = InstanceID.getInstance(getApplication());

时间:2016-07-25 09:45:19

标签: compiler-errors google-cloud-messaging

这是在显示InstanceID instanceID时显示的错误;

'android.app.AppOpsManager', referenced from method com.google.android.gms.common.GooglePlayServicesUtil.zzb
    07-25 15:08:54.919 19852-19874/? E/AndroidRuntime: FATAL EXCEPTION: IntentService[]
                                                       java.lang.IncompatibleClassChangeError: android.support.v4.content.ContextCompat
                                                           at com.google.android.gms.iid.zzd.zzdL(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 nath.prem.com.premgcmproject.GCMRegistrationIntentService.registerGCM(GCMRegistrationIntentService.java:60)
                                                           at nath.prem.com.premgcmproject.GCMRegistrationIntentService.onHandleIntent(GCMRegistrationIntentService.java:41)
                                                           at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
                                                           at android.os.Handler.dispatchMessage(Handler.java:99)
                                                           at android.os.Looper.loop(Looper.java:153)
                                                           at android.os.HandlerThread.run(HandlerThread.java:60)
    07-25 15:08:54.961 520-539/? E/AppErrorDialog: Failed to get 

1 个答案:

答案 0 :(得分:0)

尝试在build.gradle

中的依赖项中添加此内容
compile 'com.android.support:appcompat-v7:23.4.0'

此SO帖子 - IncompatibleClassChangeError after updating to Android Build Tools 25.1.6 GCM / FCM也可能对您有帮助。