簡體   English   中英

Android上的PushWoosh:運行.registerDevice()時,出現“ nullpointerexception”

[英]PushWoosh on Android: `nullpointerexception` when running .registerDevice()

我正在嘗試在Android上使用PushWoosh插件運行基於Apache Cordova的應用程序 為了避免Android上出現碎片問題,我們使用MobileChromeApps構建我們的Android版本的應用程序。 但是,我無法通過PushWoosh將設備注冊為推送消息。 該代碼可在iOS上完美運行。

一旦運行plugins.pushNotification.registerDevice ,就會發生該錯誤。

這是adb logcat給我的:

D/PushNotifications(17915): Plugin Called
W/System.err(17915): java.lang.NullPointerException
W/System.err(17915):    at com.pushwoosh.plugin.pushnotifications.PushNotifications.internalRegister(PushNotifications.java:189)
W/System.err(17915):    at com.pushwoosh.plugin.pushnotifications.PushNotifications.execute(PushNotifications.java:390)
W/System.err(17915):    at org.apache.cordova.CordovaPlugin.execute(CordovaPlugin.java:82)
W/System.err(17915):    at org.apache.cordova.PluginManager.exec(PluginManager.java:128)
W/System.err(17915):    at org.apache.cordova.CordovaBridge.jsExec(CordovaBridge.java:63)
W/System.err(17915):    at org.apache.cordova.engine.crosswalk.XWalkExposedJsApi.exec(XWalkExposedJsApi.java:40)
W/System.err(17915):    at org.chromium.base.SystemMessageHandler.nativeDoRunLoopOnce(Native Method)
W/System.err(17915):    at org.chromium.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:28)
W/System.err(17915):    at android.os.Handler.dispatchMessage(Handler.java:99)
W/System.err(17915):    at android.os.Looper.loop(Looper.java:137)
W/System.err(17915):    at android.os.HandlerThread.run(HandlerThread.java:60)

看來Java代碼以某種方式失敗了-但是我不知道為什么以及為什么(本質上是Web開發人員,我也不了解Java)。 該應用程序永遠不會調用任何遠程資源,因此該錯誤必須在應用程序設置中。

有任何想法嗎? 感謝您的所有幫助(如果您在哥本哈根,甚至可以得到啤酒來回報)。

編輯:對adb logcat -s System.err更詳細研究揭示了初始化也失敗,可能導致另一個錯誤

W/System.err( 7439): org.json.JSONException: No value for projectid
W/System.err( 7439):    at org.json.JSONObject.get(JSONObject.java:354)
W/System.err( 7439):    at org.json.JSONObject.getString(JSONObject.java:510)
W/System.err( 7439):    at com.pushwoosh.plugin.pushnotifications.PushNotifications.initialize(PushNotifications.java:174)
W/System.err( 7439):    at com.pushwoosh.plugin.pushnotifications.PushNotifications.execute(PushNotifications.java:384)
W/System.err( 7439):    at org.apache.cordova.CordovaPlugin.execute(CordovaPlugin.java:82)
W/System.err( 7439):    at org.apache.cordova.PluginManager.exec(PluginManager.java:128)
W/System.err( 7439):    at org.apache.cordova.CordovaBridge.jsExec(CordovaBridge.java:63)
W/System.err( 7439):    at org.apache.cordova.engine.crosswalk.XWalkExposedJsApi.exec(XWalkExposedJsApi.java:40)
W/System.err( 7439):    at org.chromium.base.SystemMessageHandler.nativeDoRunLoopOnce(Native Method)
W/System.err( 7439):    at org.chromium.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:28)
W/System.err( 7439):    at android.os.Handler.dispatchMessage(Handler.java:99)
W/System.err( 7439):    at android.os.Looper.loop(Looper.java:137)
W/System.err( 7439):    at android.os.HandlerThread.run(HandlerThread.java:60)
W/System.err( 7439): java.lang.NullPointerException
W/System.err( 7439):    at com.pushwoosh.plugin.pushnotifications.PushNotifications.internalRegister(PushNotifications.java:190)
W/System.err( 7439):    at com.pushwoosh.plugin.pushnotifications.PushNotifications.execute(PushNotifications.java:393)
W/System.err( 7439):    at org.apache.cordova.CordovaPlugin.execute(CordovaPlugin.java:82)
W/System.err( 7439):    at org.apache.cordova.PluginManager.exec(PluginManager.java:128)
W/System.err( 7439):    at org.apache.cordova.CordovaBridge.jsExec(CordovaBridge.java:63)
W/System.err( 7439):    at org.apache.cordova.engine.crosswalk.XWalkExposedJsApi.exec(XWalkExposedJsApi.java:40)
W/System.err( 7439):    at org.chromium.base.SystemMessageHandler.nativeDoRunLoopOnce(Native Method)
W/System.err( 7439):    at org.chromium.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:28)
W/System.err( 7439):    at android.os.Handler.dispatchMessage(Handler.java:99)
W/System.err( 7439):    at android.os.Looper.loop(Looper.java:137)
W/System.err( 7439):    at android.os.HandlerThread.run(HandlerThread.java:60)
W/System.err( 7439): java.lang.NullPointerException
W/System.err( 7439):    at com.pushwoosh.plugin.pushnotifications.PushNotifications.internalRegister(PushNotifications.java:190)
W/System.err( 7439):    at com.pushwoosh.plugin.pushnotifications.PushNotifications.execute(PushNotifications.java:393)
W/System.err( 7439):    at org.apache.cordova.CordovaPlugin.execute(CordovaPlugin.java:82)
W/System.err( 7439):    at org.apache.cordova.PluginManager.exec(PluginManager.java:128)
W/System.err( 7439):    at org.apache.cordova.CordovaBridge.jsExec(CordovaBridge.java:63)
W/System.err( 7439):    at org.apache.cordova.engine.crosswalk.XWalkExposedJsApi.exec(XWalkExposedJsApi.java:40)
W/System.err( 7439):    at org.chromium.base.SystemMessageHandler.nativeDoRunLoopOnce(Native Method)
W/System.err( 7439):    at org.chromium.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:28)
W/System.err( 7439):    at android.os.Handler.dispatchMessage(Handler.java:99)
W/System.err( 7439):    at android.os.Looper.loop(Looper.java:137)
W/System.err( 7439):    at android.os.HandlerThread.run(HandlerThread.java:60)

非常感謝!

Github問題在這里

您似乎沒有提供推送通知的憑據。 它應該在您的AndroidManifest.xml中

在這里查看第4步: https//www.pushwoosh.com/programming-push-notification/android/native-android-sdk-integration/

或在onDeviceReady函數中,請參見此處: https : //github.com/Pushwoosh/phonegap-3-sample-app/blob/master/www/js/PushwooshAndroid.js

(從一個答案開始,因為我沒有足夠的聲譽來發表評論)

您是否正在模擬器上測試推送通知? (您在Github問題中提到了“測試設備”,因此請確認一下)

我問,因為模擬器既不能訂閱也不能接收推送通知。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM