GCM取消注册导致应用程序崩溃 [英] GCM unregister causing the application to crash

查看:162
本文介绍了GCM取消注册导致应用程序崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用上实施了GCM通知。我现在试图在用户注销时取消注册应用程序。我正在使用下面的代码。当这段代码执行时,它会导致应用程序崩溃,使用以下logcat:

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)

以下是代码:

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();
}


推荐答案

将支持库更新为25.0.0。
在更新下面的库之后,在应用程序gradle文件中,问题消失了。

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")

这篇关于GCM取消注册导致应用程序崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆