GCM 取消注册导致应用程序崩溃
2022-09-01 20:17:29
我已经在我的应用上实现了 GCM 通知。我现在尝试在用户注销时取消注册应用。我正在使用以下代码。执行此代码时,它会导致应用程序崩溃,并使用以下 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)
代码如下:
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();
}