UrbanAirship NPE

编程入门 行业动态 更新时间:2024-10-23 05:40:25
本文介绍了UrbanAirship NPE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我收到以下NPE在安装我的应用程序本身。请帮助。

07-22 16:27:06.380:E / UA AP(6071):无法自动腾飞07-22 16:27:06.385:D / AndroidRuntime(6071):关闭VM07-22 16:27:06.385:W / dalvikvm(6071):主题ID = 1:螺纹未捕获的异常(组= 0x415db2a0)退出07-22 16:27:06.385:E / AndroidRuntime(6071):致命异常:主要07-22 16:27:06.385:E / AndroidRuntime(6071):了java.lang.RuntimeException:无法启动接收com.urbanairship.push.GCMPushReceiver:显示java.lang.NullPointerException07-22 16:27:06.385:E / AndroidRuntime(6071):在android.app.ActivityThread.handleReceiver(ActivityThread.java:2277)07-22 16:27:06.385:E / AndroidRuntime(6071):在android.app.ActivityThread.access $ 1500(ActivityThread.java:140)07-22 16:27:06.385:E / AndroidRuntime(6071):在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1303)07-22 16:27:06.385:E / AndroidRuntime(6071):在android.os.Handler.dispatchMessage(Handler.java:99)07-22 16:27:06.385:E / AndroidRuntime(6071):在android.os.Looper.loop(Looper.java:137)07-22 16:27:06.385:E / AndroidRuntime(6071):在android.app.ActivityThread.main(ActivityThread.java:4898)07-22 16:27:06.385:E / AndroidRuntime(6071):在java.lang.reflect.Method.invokeNative(本机方法)07-22 16:27:06.385:E / AndroidRuntime(6071):在java.lang.reflect.Method.invoke(Method.java:511)07-22 16:27:06.385:E / AndroidRuntime(6071):在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:1006)07-22 16:27:06.385:E / AndroidRuntime(6071):在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)07-22 16:27:06.385:E / AndroidRuntime(6071):在dalvik.system.NativeStart.main(本机方法)07-22 16:27:06.385:E / AndroidRuntime(6071):因:显示java.lang.NullPointerException07-22 16:27:06.385:E / AndroidRuntime(6071):在com.urbanairship.UAirship.getPackageName(来源不明)07-22 16:27:06.385:E / AndroidRuntime(6071):在com.urbanairship.push.GCMPushReceiver.onReceive(来源不明)07-22 16:27:06.385:E / AndroidRuntime(6071):在android.app.ActivityThread.handleReceiver(ActivityThread.java:2270)07-22 16:27:06.385:E / AndroidRuntime(6071):10 ...更多

虽然我得到这个除外我可以启动应用程序。上运行:

URL -X POST -u<应用程序ID>:< mastersecret>中-H内容类型:应用程序/ JSON--data{机器人:{警告:TestPushtoAPID},apids:**** 4]}的https://去.urbanairship / API /推/

我收到以下响应:

{    push_id:33e95250-f2b9-11e2-a8d0-14feb5d31f47}

在尽管如此,我无法看到我的设备上的任何通知。

Android清单的一部分<! - 需要城市飞艇GCM - ><接收机器人:名字=com.urbanairship.CoreReceiver/><接收机器人:名字=com.urbanairship.push.GCMPushReceiver机器人:权限=com.google.android.c2dm.permission.SEND>    &所述;意图滤光器>        <作用机器人:名字=com.google.android.c2dm.intent.RECEIVE/>        <作用机器人:名字=com.google.android.c2dm.intent.REGISTRATION/>    &所述; /意图滤光器>< /接收器>

MainActivity的部分:

UAirship.takeOff(this.getApplication(),选件);PushManager.enablePush();PushManager.shared()setIntentReceiver(IntentReceiver.class)。字符串APID = PushManager.shared()getAPID()。

解决方案

其实这个问题是实现图书馆的正确。

的起飞以及其他配置code应该在的OnCreate 的 应用 类,这是用于维护的全局状态的应用的。这是我们大多数人去wrong.We把它放在前台活动取值的OnCreate 。

接下来,您需要提及的全名的的应用您正在使用的 AndroidManifest类。 XML 应用程序标签中是这样的:

<应用        机器人:名字=com.popa.app.MyApplication        ..

这是如何被实现为的 原UA的文档 。

I am getting the following NPE while installing my app itself. Please help.

07-22 16:27:06.380: E/UA AP(6071): Unable to takeOff automatically 07-22 16:27:06.385: D/AndroidRuntime(6071): Shutting down VM 07-22 16:27:06.385: W/dalvikvm(6071): threadid=1: thread exiting with uncaught exception (group=0x415db2a0) 07-22 16:27:06.385: E/AndroidRuntime(6071): FATAL EXCEPTION: main 07-22 16:27:06.385: E/AndroidRuntime(6071): java.lang.RuntimeException: Unable to start receiver com.urbanairship.push.GCMPushReceiver: java.lang.NullPointerException 07-22 16:27:06.385: E/AndroidRuntime(6071): at android.app.ActivityThread.handleReceiver(ActivityThread.java:2277) 07-22 16:27:06.385: E/AndroidRuntime(6071): at android.app.ActivityThread.access$1500(ActivityThread.java:140) 07-22 16:27:06.385: E/AndroidRuntime(6071): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303) 07-22 16:27:06.385: E/AndroidRuntime(6071): at android.os.Handler.dispatchMessage(Handler.java:99) 07-22 16:27:06.385: E/AndroidRuntime(6071): at android.os.Looper.loop(Looper.java:137) 07-22 16:27:06.385: E/AndroidRuntime(6071): at android.app.ActivityThread.main(ActivityThread.java:4898) 07-22 16:27:06.385: E/AndroidRuntime(6071): at java.lang.reflect.Method.invokeNative(Native Method) 07-22 16:27:06.385: E/AndroidRuntime(6071): at java.lang.reflect.Method.invoke(Method.java:511) 07-22 16:27:06.385: E/AndroidRuntime(6071): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006) 07-22 16:27:06.385: E/AndroidRuntime(6071): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773) 07-22 16:27:06.385: E/AndroidRuntime(6071): at dalvik.system.NativeStart.main(Native Method) 07-22 16:27:06.385: E/AndroidRuntime(6071): Caused by: java.lang.NullPointerException 07-22 16:27:06.385: E/AndroidRuntime(6071): at com.urbanairship.UAirship.getPackageName(Unknown Source) 07-22 16:27:06.385: E/AndroidRuntime(6071): at com.urbanairship.push.GCMPushReceiver.onReceive(Unknown Source) 07-22 16:27:06.385: E/AndroidRuntime(6071): at android.app.ActivityThread.handleReceiver(ActivityThread.java:2270) 07-22 16:27:06.385: E/AndroidRuntime(6071): ... 10 more

Even though I get this excepting I am able to start the app. On running :

url -X POST -u "<app id>:<mastersecret>" -H "Content-Type: application/json" --data '{"android": {"alert": "TestPushtoAPID"}, "apids": ["****4"]}' go.urbanairship/api/push/

I am getting the following response :

{ "push_id": "33e95250-f2b9-11e2-a8d0-14feb5d31f47" }

In spite of this, I am not able to see any notification on my device.

Part of Android Manifest <!-- REQUIRED for Urban Airship GCM--> <receiver android:name="com.urbanairship.CoreReceiver" /> <receiver android:name="com.urbanairship.push.GCMPushReceiver" android:permission="com.google.android.c2dm.permission.SEND"> <intent-filter> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> <action android:name="com.google.android.c2dm.intent.REGISTRATION" /> </intent-filter> </receiver>

Part of MainActivity:

UAirship.takeOff(this.getApplication(), options); PushManager.enablePush(); PushManager.shared().setIntentReceiver(IntentReceiver.class); String apid = PushManager.shared().getAPID();

解决方案

Actually the problem was in implementation of the library correctly.

The takeOff as well as the other configuration code should be in the OnCreate of the Application class which is used for maintaining global state of the application.This is where most of us go wrong.We put it in the foreground Activitys OnCreate.

Next you need to mention the fully qualified name of the Application class which you are using in the AndroidManifest.xml within your application tag this way:

<application android:name="com.popa.app.MyApplication" ..

This is how it is to be implemented as mentioned in the original docs of UA.

更多推荐

UrbanAirship NPE

本文发布于:2023-10-31 06:02:31,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1545226.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:UrbanAirship   NPE

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!