Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intent is null in GCMBaseIntentService.onHandleIntent #20

Closed
GoogleCodeExporter opened this issue Mar 17, 2015 · 13 comments
Closed

Intent is null in GCMBaseIntentService.onHandleIntent #20

GoogleCodeExporter opened this issue Mar 17, 2015 · 13 comments

Comments

@GoogleCodeExporter
Copy link

@GoogleCodeExporter GoogleCodeExporter commented Mar 17, 2015

I rarely saw this error in my app.
java.lang.NullPointerException
    at com.google.android.gcm.GCMBaseIntentService.onHandleIntent(GCMBaseIntentService.java:194)
    at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:137)
    at android.os.HandlerThread.run(HandlerThread.java:60)

It seems Intent is null in onHandleIntent.
I heard intent could be null with START_STICKY but IntentService doesn't use 
this.
How could this happen? Any idea?

Original issue reported on code.google.com by noranb...@gmail.com on 4 Apr 2013 at 6:39

@GoogleCodeExporter

This comment has been minimized.

Copy link
Author

@GoogleCodeExporter GoogleCodeExporter commented Mar 17, 2015

Git this bug too.

It seems (from source code) that action is null: 
https://code.google.com/p/gcm/source/browse/gcm-client/src/com/google/android/gc
m/GCMBaseIntentService.java?r=3f8285f108caecf9ee040cdadda3a024b81f7e3e#194

This bug seems to happen on Android 4.x.x versions

Here's some datas: http://ge.tt/3CNt5Fl?c

Original comment by stermi on 8 Jul 2013 at 3:23

@GoogleCodeExporter

This comment has been minimized.

Copy link
Author

@GoogleCodeExporter GoogleCodeExporter commented Mar 17, 2015

You might get this if you extends the GCMBaseIntentService and call 
super.onStartCommand(Intent, int int).

Original comment by jonas.es...@gmail.com on 22 Aug 2013 at 7:24

@GoogleCodeExporter

This comment has been minimized.

Copy link
Author

@GoogleCodeExporter GoogleCodeExporter commented Mar 17, 2015

I also see these exceptions.  GCMBaseIntentService is crashing.  Can you please 
add some protection to prevent this? Below is a sample.  There is no call to 
super.onStartCommand() in the app's subclass.

log: Sep 6, 2013 5:29:25 AM

SEVERE: uncaught: 
Throwable occurred: java.lang.NullPointerException
    at com.google.android.gcm.GCMBaseIntentService.onHandleIntent(SourceFile:194)
    at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:137)
    at android.os.HandlerThread.run(HandlerThread.java:60)

sys: 

android.version: 4.1.2
brand/model: Verizon/SCH-I605


Original comment by larha...@gmail.com on 6 Sep 2013 at 3:58

@GoogleCodeExporter

This comment has been minimized.

Copy link
Author

@GoogleCodeExporter GoogleCodeExporter commented Mar 17, 2015

Yeah, My app get NPE also, any solution for this?

java.lang.NullPointerException
at 
com.google.android.gcm.GCMBaseIntentService.onHandleIntent(GCMBaseIntentService.
java:194)
at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.os.HandlerThread.run(HandlerThread.java:60)

Original comment by davidbil...@gmail.com on 7 Oct 2013 at 2:36

@GoogleCodeExporter

This comment has been minimized.

Copy link
Author

@GoogleCodeExporter GoogleCodeExporter commented Mar 17, 2015

Comment on #1
Exception is thrown on line 194:

    String action = intent.getAction();

This clearly indicate that intent itself is null and not an action.

Original comment by idolon....@gmail.com on 26 Mar 2014 at 4:01

@GoogleCodeExporter

This comment has been minimized.

Copy link
Author

@GoogleCodeExporter GoogleCodeExporter commented Mar 17, 2015

got the same NPE on SCH-I535, android 4.3

Original comment by Roman.Ya...@gmail.com on 1 Apr 2014 at 1:57

@GoogleCodeExporter

This comment has been minimized.

Copy link
Author

@GoogleCodeExporter GoogleCodeExporter commented Mar 17, 2015

I see this issue as well. Any resolutions ?

Original comment by vij...@gmail.com on 1 Oct 2014 at 5:03

@GoogleCodeExporter

This comment has been minimized.

Copy link
Author

@GoogleCodeExporter GoogleCodeExporter commented Mar 17, 2015

As a workaround you can add onStart method to your service:

  @Override
  public void onStart(Intent intent, int startId) {
    if (intent != null) {
      super.onStart(intent, startId);
    }
  }

Original comment by volodymy...@gmail.com on 1 Oct 2014 at 9:57

@silvolu

This comment has been minimized.

Copy link
Member

@silvolu silvolu commented Sep 2, 2015

This has been fixed in the new API.

@silvolu silvolu closed this Sep 2, 2015
sealskej pushed a commit to 8fit/OneSignal-Android-SDK that referenced this issue Dec 17, 2015
@Hemant0601

This comment has been minimized.

Copy link

@Hemant0601 Hemant0601 commented May 26, 2016

@silvolu I am still getting this issue. what changes I need to do to fix this?

@kroikie

This comment has been minimized.

Copy link
Contributor

@kroikie kroikie commented May 26, 2016

What version of the API are you using?

@Hemant0601

This comment has been minimized.

Copy link

@Hemant0601 Hemant0601 commented Jun 1, 2016

@kroikie how can i get the version of the API? this is my gradle inclusion though
compile 'com.google.android.gms:play-services-gcm:8.4.0'

@ogeidix

This comment has been minimized.

Copy link
Contributor

@ogeidix ogeidix commented Jun 1, 2016

Hi @Hemant0601. From your previous post you can see that you are using the version 8.4.0.
The latest version of the GCM library is:
compile 'com.google.android.gms:play-services-gcm:9.0.1'

Also you might want to check the new Firebase Cloud Messaging sdk:
https://firebase.google.com/docs/cloud-messaging/
This is a major update of the GCM library with new a integration with the Firebase platform.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.