【问题标题】:Worklight app crashes when receiving push notificationWorklight 应用程序在收到推送通知时崩溃
【发布时间】:2014-10-09 13:13:18
【问题描述】:

您好,我已经为 Android 开发了一个 Worklight 应用程序,它使用 Bluemix IBM Push,当我收到通知时,如果应用程序关闭,它可以正常工作并打开应用程序,但是当应用程序打开时,应用程序崩溃并显示以下内容错误。

10-09 18:13:00.676: E/AndroidRuntime(4665): FATAL EXCEPTION: main
10-09 18:13:00.676: E/AndroidRuntime(4665): java.lang.ClassCastException: com.ibm.mobile.services.push.internal.InternalPushMessage cannot be cast to com.worklight.androidgap.push.GCMIntentService$Message
10-09 18:13:00.676: E/AndroidRuntime(4665):     at com.worklight.androidgap.plugin.Push.onNewIntent(Push.java:193)
10-09 18:13:00.676: E/AndroidRuntime(4665):     at org.apache.cordova.PluginManager.onNewIntent(PluginManager.java:371)
10-09 18:13:00.676: E/AndroidRuntime(4665):     at org.apache.cordova.CordovaWebView.onNewIntent(CordovaWebView.java:874)
10-09 18:13:00.676: E/AndroidRuntime(4665):     at org.apache.cordova.CordovaActivity.onNewIntent(CordovaActivity.java:702)
10-09 18:13:00.676: E/AndroidRuntime(4665):     at android.app.Instrumentation.callActivityOnNewIntent(Instrumentation.java:1225)
10-09 18:13:00.676: E/AndroidRuntime(4665):     at android.app.ActivityThread.deliverNewIntents(ActivityThread.java:2472)
10-09 18:13:00.676: E/AndroidRuntime(4665):     at android.app.ActivityThread.performNewIntents(ActivityThread.java:2485)
10-09 18:13:00.676: E/AndroidRuntime(4665):     at android.app.ActivityThread.handleNewIntent(ActivityThread.java:2494)
10-09 18:13:00.676: E/AndroidRuntime(4665):     at android.app.ActivityThread.access$1400(ActivityThread.java:165)
10-09 18:13:00.676: E/AndroidRuntime(4665):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1444)
10-09 18:13:00.676: E/AndroidRuntime(4665):     at android.os.Handler.dispatchMessage(Handler.java:107)
10-09 18:13:00.676: E/AndroidRuntime(4665):     at android.os.Looper.loop(Looper.java:194)
10-09 18:13:00.676: E/AndroidRuntime(4665):     at android.app.ActivityThread.main(ActivityThread.java:5391)
10-09 18:13:00.676: E/AndroidRuntime(4665):     at java.lang.reflect.Method.invokeNative(Native Method)
10-09 18:13:00.676: E/AndroidRuntime(4665):     at java.lang.reflect.Method.invoke(Method.java:525)
10-09 18:13:00.676: E/AndroidRuntime(4665):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
10-09 18:13:00.676: E/AndroidRuntime(4665):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
10-09 18:13:00.676: E/AndroidRuntime(4665):     at dalvik.system.NativeStart.main(Native Method)
10-09 18:13:00.677: D/WLClient(4665): WLClient$ActivityListener.onActivityPaused in WLClient.java:1155 :: on activity paused com.Techathon.Techathon . activity count = 0
10-09 18:13:00.683: D/NONE(4665): Flush called
10-09 18:13:00.718: E/com.worklight.common.Logger$UncaughtExceptionHandler(4665): Logger$UncaughtExceptionHandler.uncaughtException in Logger.java:402 :: Uncaught Exception
10-09 18:13:00.718: E/com.worklight.common.Logger$UncaughtExceptionHandler(4665): java.lang.ClassCastException: com.ibm.mobile.services.push.internal.InternalPushMessage cannot be cast to com.worklight.androidgap.push.GCMIntentService$Message
10-09 18:13:00.718: E/com.worklight.common.Logger$UncaughtExceptionHandler(4665):   at com.worklight.androidgap.plugin.Push.onNewIntent(Push.java:193)
10-09 18:13:00.718: E/com.worklight.common.Logger$UncaughtExceptionHandler(4665):   at org.apache.cordova.PluginManager.onNewIntent(PluginManager.java:371)
10-09 18:13:00.718: E/com.worklight.common.Logger$UncaughtExceptionHandler(4665):   at org.apache.cordova.CordovaWebView.onNewIntent(CordovaWebView.java:874)
10-09 18:13:00.718: E/com.worklight.common.Logger$UncaughtExceptionHandler(4665):   at org.apache.cordova.CordovaActivity.onNewIntent(CordovaActivity.java:702)
10-09 18:13:00.718: E/com.worklight.common.Logger$UncaughtExceptionHandler(4665):   at android.app.Instrumentation.callActivityOnNewIntent(Instrumentation.java:1225)
10-09 18:13:00.718: E/com.worklight.common.Logger$UncaughtExceptionHandler(4665):   at android.app.ActivityThread.deliverNewIntents(ActivityThread.java:2472)
10-09 18:13:00.718: E/com.worklight.common.Logger$UncaughtExceptionHandler(4665):   at android.app.ActivityThread.performNewIntents(ActivityThread.java:2485)
10-09 18:13:00.718: E/com.worklight.common.Logger$UncaughtExceptionHandler(4665):   at android.app.ActivityThread.handleNewIntent(ActivityThread.java:2494)
10-09 18:13:00.718: E/com.worklight.common.Logger$UncaughtExceptionHandler(4665):   at android.app.ActivityThread.access$1400(ActivityThread.java:165)
10-09 18:13:00.718: E/com.worklight.common.Logger$UncaughtExceptionHandler(4665):   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1444)
10-09 18:13:00.718: E/com.worklight.common.Logger$UncaughtExceptionHandler(4665):   at android.os.Handler.dispatchMessage(Handler.java:107)
10-09 18:13:00.718: E/com.worklight.common.Logger$UncaughtExceptionHandler(4665):   at android.os.Looper.loop(Looper.java:194)
10-09 18:13:00.718: E/com.worklight.common.Logger$UncaughtExceptionHandler(4665):   at android.app.ActivityThread.main(ActivityThread.java:5391)
10-09 18:13:00.718: E/com.worklight.common.Logger$UncaughtExceptionHandler(4665):   at java.lang.reflect.Method.invokeNative(Native Method)
10-09 18:13:00.718: E/com.worklight.common.Logger$UncaughtExceptionHandler(4665):   at java.lang.reflect.Method.invoke(Method.java:525)
10-09 18:13:00.718: E/com.worklight.common.Logger$UncaughtExceptionHandler(4665):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
10-09 18:13:00.718: E/com.worklight.common.Logger$UncaughtExceptionHandler(4665):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
10-09 18:13:00.718: E/com.worklight.common.Logger$UncaughtExceptionHandler(4665):   at dalvik.system.NativeStart.main(Native Method)
10-09 18:13:02.586: I/Process(4665): Sending signal. PID: 4665 SIG: 9

我已经根据此处提供的链接设置了我的环境http://mbaas-gettingstarted.ng.bluemix.net/hybrid

【问题讨论】:

    标签: android push-notification ibm-mobilefirst ibm-cloud


    【解决方案1】:

    您是否尝试过编辑您的 AndroidManifest.xml 以删除对 GCMIntentService 的引用?

    您也许可以按照此处的说明注释掉这些部分: https://developer.ibm.com/answers/questions/19343/double-push-notifications/?smartspace=bluemix

    这样,您将只使用 Bluemix Push SDK 来响应推送通知。希望完全避免这个错误。

    编辑:玩了一段时间后,我发现 Push 插件应该归咎于 SDK 冲突。在我注释掉 config.xml 中的 Worklight Push 插件后,错误消失了。

    评论这些行并重试:

    <feature name="Push">
         <param name="android-package" value="com.worklight.androidgap.plugin.Push" />
    </feature>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-06-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多