app engine(eclipse): can't register device fro

2019-08-26 01:47发布

I am just started exploring app engine with android and I followed a link to teach me how to create aApp Engine Connected Android Project. https://developers.google.com/eclipse/docs/endpoints-androidconnected-gae

I followed exactly what was written in the link ,

1) Created a new app engine connected android project

2) Get the project number and API Keys from https://code.google.com/apis/console/#project

3) enable Google Cloud Messaging in the Google APIs Console

4) set the LOCAL_ANDROID_RUN to true in CloudEndpoints class

5) used a emulator with google api(v17)

6) installed the android cloud messaging library from android sdk manager

7) I am using eclipse indigo

I started the localhost:8888 and it's work perfectly fine on the web but when I run the emulator and I pressed on the register button , it stopped immediately and I check my logcat, It display this error which I don't what I should do about it

    03-26 13:03:48.766: E/AndroidRuntime(915): FATAL EXCEPTION: IntentService[GCMIntentService-525241845095-1]
    03-26 13:03:48.766: E/AndroidRuntime(915): java.lang.NullPointerException
    03-26 13:03:48.766: E/AndroidRuntime(915):  at       com.tesst.GCMIntentService.onRegistered(GCMIntentService.java:144)
    03-26 13:03:48.766: E/AndroidRuntime(915):  at com.google.android.gcm.GCMBaseIntentService.handleRegistration(GCMBaseIntentService.java:251)
    03-26 13:03:48.766: E/AndroidRuntime(915):  at com.google.android.gcm.GCMBaseIntentService.onHandleIntent(GCMBaseIntentService.java:153)
    03-26 13:03:48.766: E/AndroidRuntime(915):  at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
    03-26 13:03:48.766: E/AndroidRuntime(915):  at android.os.Handler.dispatchMessage(Handler.java:99)
    03-26 13:03:48.766: E/AndroidRuntime(915):  at android.os.Looper.loop(Looper.java:137)
    03-26 13:03:48.766: E/AndroidRuntime(915):  at android.os.HandlerThread.run(HandlerThread.java:60)

appreciate if anyone can help me solve my issue that I am having. Thanks

1条回答
爷、活的狠高调
2楼-- · 2019-08-26 02:31

Looking at this narrowly, it is likely that existingInfo is null.

More broadly, it appears that in your onRegistered function you execute an endpoint. For starters, invoking an endpoint is a synchronous operation so it shouldn't be done in onRegistered.

If I am understanding your code correctly, you should change that. I would suggest you should 'de-couple' your GCM code from your endpoints code.

Also, I suggest you review the instructions for implementing GCM:
http://developer.android.com/google/gcm/gs.html

查看更多
登录 后发表回答