3

我无法弄清楚这一点,在我的一个测试应用程序中,关闭应用程序时出现错误。

在 LogCat 中,我看到 handleRegistration 长代码正常,以蓝色文本显示,但在将 regId 保存在应用程序上后的一些行中,注册码以红色文本显示。

有人知道为什么吗?

在另一个应用程序中,在同一个模拟器中,它不会发生,但我找不到解决方案。

编辑

你是对的,对不起,这是 LogCat 输出:

10-26 12:22:11.383: I/dalvikvm(754): threadid=3: reacting to signal 3
10-26 12:22:11.539: I/dalvikvm(754): Wrote stack traces to '/data/anr/traces.txt'
10-26 12:22:11.644: I/dalvikvm(754): threadid=3: reacting to signal 3
10-26 12:22:11.718: I/dalvikvm(754): Wrote stack traces to '/data/anr/traces.txt'
10-26 12:22:11.873: D/GCMRegistrar(754): resetting backoff for nl.easy.gcmnotification
10-26 12:22:11.883: V/GCMRegistrar(754): Registering app nl.easy.gcmnotification of senders 182xxxxxx601
10-26 12:22:12.153: I/dalvikvm(754): threadid=3: reacting to signal 3
10-26 12:22:12.163: I/dalvikvm(754): Wrote stack traces to '/data/anr/traces.txt'
10-26 12:22:12.445: D/gralloc_goldfish(754): Emulator without GPU emulation detected.
10-26 12:22:13.843: V/GCMBroadcastReceiver(754): onReceive: 
com.google.android.c2dm.intent.REGISTRATION
10-26 12:22:13.843: V/GCMBroadcastReceiver(754): GCM IntentService class: nl.easy.gcmnotification.GCMIntentService
10-26 12:22:13.853: V/GCMBaseIntentService(754): Acquiring wakelock
10-26 12:22:13.864: V/GCMBaseIntentService(754): Intent service name: GCMIntentService-182537982601-1
10-26 12:22:13.953: E/GCMRegistrar(754): internal error: retry receiver class not set yet
10-26 12:22:13.953: V/GCMRegistrar(754): Registering receiver
10-26 12:22:13.953: D/GCMBaseIntentService(754): handleRegistration: registrationId = APAxxxxxx8Kg, error = null, unregistered = null (IN COLOR BLUE)
10-26 12:22:13.953: D/GCMRegistrar(754): resetting backoff for nl.easy.gcmnotification
10-26 12:22:13.964: V/GCMRegistrar(754): Saving regId on app version 1
10-26 12:22:13.973: E/(754): registration id : APAxxxxxx8Kg (IN COLOR RED)
10-26 12:22:13.973: V/GCMBaseIntentService(754): Releasing wakelock
(WHEN SHUTTING DOWN APP)
10-26 12:22:35.033: V/GCMRegistrar(754): Unregistering receiver
10-26 12:22:35.033: D/AndroidRuntime(754): Shutting down VM
10-26 12:22:35.033: W/dalvikvm(754): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
10-26 12:22:35.155: E/AndroidRuntime(754): FATAL EXCEPTION: main
10-26 12:22:35.155: E/AndroidRuntime(754): java.lang.RuntimeException: Unable to destroy activity {nl.easy.gcmnotification/nl.easy.gcmnotification.MainActivity}: java.lang.IllegalArgumentException: Receiver not registered: com.google.android.gcm.GCMBroadcastReceiver@412bc5c0
10-26 12:22:35.155: E/AndroidRuntime(754):  at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3112)
10-26 12:22:35.155: E/AndroidRuntime(754):  at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3130)
10-26 12:22:35.155: E/AndroidRuntime(754):  at android.app.ActivityThread.access$1200(ActivityThread.java:123)
10-26 12:22:35.155: E/AndroidRuntime(754):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1180)
10-26 12:22:35.155: E/AndroidRuntime(754):  at android.os.Handler.dispatchMessage(Handler.java:99)
10-26 12:22:35.155: E/AndroidRuntime(754):  at android.os.Looper.loop(Looper.java:137)
10-26 12:22:35.155: E/AndroidRuntime(754):  at android.app.ActivityThread.main(ActivityThread.java:4424)
10-26 12:22:35.155: E/AndroidRuntime(754):  at java.lang.reflect.Method.invokeNative(Native Method)
10-26 12:22:35.155: E/AndroidRuntime(754):  at java.lang.reflect.Method.invoke(Method.java:511)
10-26 12:22:35.155: E/AndroidRuntime(754):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
10-26 12:22:35.155: E/AndroidRuntime(754):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
10-26 12:22:35.155: E/AndroidRuntime(754):  at dalvik.system.NativeStart.main(Native Method)
10-26 12:22:35.155: E/AndroidRuntime(754): Caused by: java.lang.IllegalArgumentException: Receiver not registered: com.google.android.gcm.GCMBroadcastReceiver@412bc5c0
10-26 12:22:35.155: E/AndroidRuntime(754):  at android.app.LoadedApk.forgetReceiverDispatcher(LoadedApk.java:628)
10-26 12:22:35.155: E/AndroidRuntime(754):  at android.app.ContextImpl.unregisterReceiver(ContextImpl.java:1066)
10-26 12:22:35.155: E/AndroidRuntime(754):  at android.content.ContextWrapper.unregisterReceiver(ContextWrapper.java:354)
10-26 12:22:35.155: E/AndroidRuntime(754):  at com.google.android.gcm.GCMRegistrar.onDestroy(GCMRegistrar.java:266)
10-26 12:22:35.155: E/AndroidRuntime(754):  at nl.easy.gcmnotification.MainActivity.onDestroy(MainActivity.java:49)
10-26 12:22:35.155: E/AndroidRuntime(754):  at android.app.Activity.performDestroy(Activity.java:4629)
10-26 12:22:35.155: E/AndroidRuntime(754):  at android.app.Instrumentation.callActivityOnDestroy(Instrumentation.java:1079)
10-26 12:22:35.155: E/AndroidRuntime(754):  at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3099)
10-26 12:22:35.155: E/AndroidRuntime(754):  ... 11 more
4

2 回答 2

0

通过重新启动eclipse并清理/重建项目来解决问题......奇怪但真实!

于 2012-11-23T13:49:49.060 回答
0

您可以发布用于破坏活动的代码吗?

我认为您的问题与此问题相同: GCMRegistrar.onDestroy(context) crashing, Receiver not registered

另一个潜在问题:您是否在清单中声明了该服务?

于 2012-11-19T15:11:25.733 回答