fatal exception in IntentService[GCMIntentService-GCMIntentService-2

1,630 views
Skip to first unread message

Vinod A

unread,
Feb 15, 2013, 4:43:40 AM2/15/13
to andro...@googlegroups.com

Hi,


I follow the tutorial in the link http://devgirl.org/2012/10/25/tutorial-android-push-notifications-with-phonegap/#comment-13282   I could successfully get the reg id back from Google.
I am using server side script from http://www.androidhive.info/2012/10/android-push-notifications-using-google-cloud-messaging-gcm-php-and-mysql/
But when I send message from server the app crashes and please find my log here

—–
02-14 17:36:13.684: E/AndroidRuntime(377): FATAL EXCEPTION: IntentService[GCMIntentService-GCMIntentService-2]
02-14 17:36:13.684: E/AndroidRuntime(377): java.lang.NullPointerException: println needs a message
02-14 17:36:13.684: E/AndroidRuntime(377): at android.util.Log.println_native(Native Method)
02-14 17:36:13.684: E/AndroidRuntime(377): at android.util.Log.v(Log.java:116)
02-14 17:36:13.684: E/AndroidRuntime(377): at com.cordova2.gcm.GCMIntentService.onMessage(GCMIntentService.java:63)
02-14 17:36:13.684: E/AndroidRuntime(377): at com.google.android.gcm.GCMBaseIntentService.onHandleIntent(GCMBaseIntentService.java:179)
02-14 17:36:13.684: E/AndroidRuntime(377): at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:59)
02-14 17:36:13.684: E/AndroidRuntime(377): at android.os.Handler.dispatchMessage(Handler.java:99)
02-14 17:36:13.684: E/AndroidRuntime(377): at android.os.Looper.loop(Looper.java:130)
02-14 17:36:13.684: E/AndroidRuntime(377): at android.os.HandlerThread.run(HandlerThread.java:60)
02-14 17:36:13.757: D/DroidGap(377): Paused the application!
——-

what may be the reasons for this issue. Please advice.
Regards,
Vinod

Vincent Debout

unread,
Feb 15, 2013, 6:50:22 AM2/15/13
to andro...@googlegroups.com

Hi,

You have the code and you have the error, you should be able to find out.


02-14 17:36:13.684: E/AndroidRuntime(377): FATAL EXCEPTION: IntentService[GCMIntentService-GCMIntentService-2]
02-14 17:36:13.684: E/AndroidRuntime(377): java.lang.NullPointerException: println needs a message
...

02-14 17:36:13.684: E/AndroidRuntime(377): at com.cordova2.gcm.GCMIntentService.onMessage(GCMIntentService.java:63)

Regards,
Vincent

Vinod A

unread,
Feb 16, 2013, 1:38:30 AM2/16/13
to andro...@googlegroups.com
Yes, the problem was variable mismatch in server and client program.  if (isset($_GET["regId"]) && isset($_GET["message"])) {
    $regId = $_GET["regId"];
    $message = $_GET["message"];
   
    include_once './GCM.php';
   
    $gcm = new GCM();

    $registatoin_ids = array($regId);
    //$message = array("price" => $message);
    $message = array("message" => $message);

    $result = $gcm->send_notification($registatoin_ids, $message);

    echo $result;
}
I have replaced red colored text to green one, Now it works.

sujeeth menon

unread,
Jan 24, 2018, 8:56:23 AM1/24/18
to android-gcm
HI ,

I am also getting the same error . Could you please help me  to resolve. 

Please find my below server side code

<?php
#API access key from Google API's Console
    define( 'API_ACCESS_KEY', 'AAAAAmKJb7c:APA91bEs8Ro_0IcZ2W5NUMqwNYspunA-6rIOFL2CAZiDnH5YY0w9nJBbbSJjjrQ6kXTyYKbFdH7WsMqVOqTR-RAIdEHPxSEV94rac7MX5fbWQ3-1RgKxT2aT0rI_aXam2Y2c6AyqK1-t' );
    $registrationIds = $_GET['id'];
$registrationIds ='APA91bEWjE0SdmE3PyzB2EFpDoKezojPbY3ur2lSg6E_PQ6Vglh_9YHtVqQAZNEA8ij806Zhz_XqJCId4MIAK8GEv0kD-6BM9C_OELIdUfwgZ2w1OBS31tU';
     $msg = array
          (
'body' => 'Body  Of Notification',
'title' => 'Push Notification',
              'icon' => 'myicon',
              'sound' => 'mySound'
          );
$fields = array
(
'to' => $registrationIds,
'notification' => $msg
);
$headers = array
(
'Authorization: key=' . API_ACCESS_KEY,
'Content-Type: application/json'
);
#Send Reponse To FireBase Server


$ch = curl_init();
curl_setopt( $ch,CURLOPT_URL, 'https://fcm.googleapis.com/fcm/send' );
curl_setopt( $ch,CURLOPT_POST, true );
curl_setopt( $ch,CURLOPT_HTTPHEADER, $headers );
curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch,CURLOPT_SSL_VERIFYPEER, false );
curl_setopt( $ch,CURLOPT_POSTFIELDS, json_encode( $fields ) );
$result = curl_exec($ch );
curl_close( $ch );
#Echo Result Of FireBase Server
echo "--****--";
echo $result;

Diego Giorgini

unread,
Jan 26, 2018, 1:35:51 AM1/26/18
to andro...@googlegroups.com
Please report a bug to Firebase Support including client side logs and information such as the version SDK you are using.
A set of steps to reproduce it would be great, but not required.

--
You received this message because you are subscribed to the Google Groups "android-gcm" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-gcm...@googlegroups.com.
To post to this group, send email to andro...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-gcm/5d03b84a-7c06-4f75-bd0e-02585071d063%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages