찾다

 >  Q&A  >  본문

android - 安卓AVOS-cloud 消息推送报错

试用了AVOS-cloud 的安卓推送。
跟着 Android 消息推送的文档,可是一直报错。

03-14 14:31:31.304: E/AndroidRuntime(13791): FATAL EXCEPTION: main
03-14 14:31:31.304: E/AndroidRuntime(13791): java.lang.RuntimeException: Unable to create service com.avos.avoscloud.PushService: java.lang.NullPointerException
03-14 14:31:31.304: E/AndroidRuntime(13791):    at android.app.ActivityThread.handleCreateService(ActivityThread.java:2651)
03-14 14:31:31.304: E/AndroidRuntime(13791):    at android.app.ActivityThread.access$1600(ActivityThread.java:150)
03-14 14:31:31.304: E/AndroidRuntime(13791):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1380)
03-14 14:31:31.304: E/AndroidRuntime(13791):    at android.os.Handler.dispatchMessage(Handler.java:99)
03-14 14:31:31.304: E/AndroidRuntime(13791):    at android.os.Looper.loop(Looper.java:213)
03-14 14:31:31.304: E/AndroidRuntime(13791):    at android.app.ActivityThread.main(ActivityThread.java:5225)
03-14 14:31:31.304: E/AndroidRuntime(13791):    at java.lang.reflect.Method.invokeNative(Native Method)
03-14 14:31:31.304: E/AndroidRuntime(13791):    at java.lang.reflect.Method.invoke(Method.java:525)
03-14 14:31:31.304: E/AndroidRuntime(13791):    at     com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
03-14 14:31:31.304: E/AndroidRuntime(13791):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
03-14 14:31:31.304: E/AndroidRuntime(13791):    at dalvik.system.NativeStart.main(Native Method)
03-14 14:31:31.304: E/AndroidRuntime(13791): Caused by: java.lang.NullPointerException
03-14 14:31:31.304: E/AndroidRuntime(13791):    at com.avos.avoscloud.AVInstallation.getCurrentInstallation(AVInstallation.java:38)
03-14 14:31:31.304: E/AndroidRuntime(13791):    at com.avos.avoscloud.PushService.onCreate(PushService.java:59)
03-14 14:31:31.304: E/AndroidRuntime(13791):    at android.app.ActivityThread.handleCreateService(ActivityThread.java:2641)
03-14 14:31:31.304: E/AndroidRuntime(13791):    ... 10 more

有人遇到同样的问题吗?

PHPzPHPz2772일 전586

모든 응답(1)나는 대답할 것이다

  • 迷茫

    迷茫2017-04-17 11:35:23

    请确保在Application中初始化AVOSCloud。

    public class MyApplication extends Application 
    { 
       public void onCreate() { 
         AVOSCloud.useAVCloudCN();
         AVOSCloud.initialize(this, "yourAppId", "yourAppKey"); 
       }
    }
    

    회신하다
    0
  • 취소회신하다