GCM unregister causing the application to crash

Zeeshan Ali :

I've implemented GCM notifications on my app. I am now trying to un-register the app when the user logs out. I am using the following code. When this code executes, it causes the application to crash with the following logcat:

java.lang.IllegalAccessError: Method 'void android.support.v4.content.ContextCompat.<init>()' is inaccessible to class 'com.google.android.gms.iid.zzd' (declaration of 'com.google.android.gms.iid.zzd' appears in /data/app/com.example.packagename-1/base.apk)
    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.zaryans.updatedepoultry.WelcomeActivity$11.onItemClick(WelcomeActivity.java:469)
    at android.widget.AdapterView.performItemClick(AdapterView.java:310)
    at android.widget.AbsListView.performItemClick(AbsListView.java:1145)
    at android.widget.AbsListView$PerformClick.run(AbsListView.java:3066)
    at android.widget.AbsListView$3.run(AbsListView.java:3903)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:148)
    at android.app.ActivityThread.main(ActivityThread.java:5417)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

Here is the code:

InstanceID instanceID = InstanceID.getInstance(WelcomeActivity.this);
try {
   instanceID.deleteInstanceID();
   Utility.logCatMsg("Logged Out Success!!!");
} catch (IOException e) {
   Utility.logCatMsg("Exception while logging out: "+e.getMessage());
   e.printStackTrace();
}
luizMello :

I was with same problem after update the support library to 25.0.0 . For me after update the below libs,in the app gradle file, the problem gone.

compile("com.google.android.gms:play-services-location:9.6.1")
compile("com.google.android.gms:play-services-maps:9.6.1")
compile("com.google.android.gms:play-services-gcm:9.6.1")

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=426558&siteId=1