0

I had everything working, but suddenly, when I call

*UPDATE 1 : This is happening on an LG L5, but working normally on Samsung Galaxy s3

regid = gcm.register(Constants.SENDER_ID);

I get an exception of : SERVICE_NOT_AVAILABLE

I did what Google tells to do and set a button to retry whenever such an exception occurs, however I still get the above exception

I checked the following :

  1. Time and date are correct.
  2. The device has a sim.
  3. Google play services is installed. As I said, it was working, but suddenly stopped. Could this be from google's end as their servers might be overloaded ?
tony9099
  • 4,567
  • 9
  • 44
  • 73

2 Answers2

0

SERVICE_NOT_AVAILABLE might mean that your device can't read the response or there was a 500/503 from the server. You said you have a re-try button but Google suggests to have an exponential back-off and then your application should itself try following that exponential back-off time.

Also check if you have "com.google.android.c2dm.intent.REGISTRATION" added to the GCMBroadcastReceiver in your manifest and you are handling that. Check out : GCM SERVICE_NOT_AVAILABLE on Android 2.2 for detailed solution, if you haven't already. Comment if that works.

Community
  • 1
  • 1
Shobhit Puri
  • 25,769
  • 11
  • 95
  • 124
  • SERVICE_NOT_AVAILABLE might mean that your device can't read the response or there was a 500/503 from the server. -- How to know which one ?--------------// If there is an error, don't just keep trying to Require the user to click a button again, or exponential back-off.-- so both work. -----------I am targeting minimum sdk 15, and yes I do have the "com.google.android.c2dm.intent.REGISTRATION" added. STILL DOES NOT WORK. – tony9099 Aug 25 '13 at 10:08
  • @tony9099 okay. First of all in case you are not aware, in internet language, the CAPS words seems like you are screaming. So, please don't scream. Secondly, for differentiating between the two I think you can check at the response that you are getting on your 3rd party server. Read under heading [Response format](http://java.llp2.dcc.ufmg.br/apiminer/static/docs/google/gcm/gcm.html#server) . If you receive 500 code in response there, then its a server error else not. Hope this helps. – Shobhit Puri Aug 25 '13 at 10:18
  • Im sorry if it appeared that way. I wasn't really shouting :). ---- Actually, I am not doing any server side work, I'm just getting the regID via gcm.register(Constants.SENDER_ID) and upon receiving, I am entering it into my online DB. – tony9099 Aug 25 '13 at 12:47
  • 1
    Its alright buddy :) okay. One more thing you can check: See if you have `YOUR_PACKAGE_NAME.GCMBroadcastReceiver` in `android:name` inside your receiver `` . Also sometimes it happens that you receive the error but also receive the registration ID in onRecieve method in GcmBroadcastReceive. See if that's happening with you. – Shobhit Puri Aug 25 '13 at 12:54
  • I tried the above suggestions. It did not work out. What makes it worse, is that the code is untouched and it was working flawlessly before a while. Btw, do I need to implement GcmIntentService.java or it is not a must ? As I do not implement it. – tony9099 Aug 25 '13 at 13:07
  • Yes it is must. Otherwise where you'll receive the registration ID. You get it when you override onRegistered method inside that service like: `@Override public void onRegistered(Context context, String regId)`. If you are not having this then the cause of error is this. Remember I wrote in first like that `either hat your device can't read the response..`. I meant that you are not handling the response. – Shobhit Puri Aug 25 '13 at 13:15
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/36197/discussion-between-tony9099-and-shobhit-puri) – tony9099 Aug 25 '13 at 13:16
  • At the time being, reverting to the old api for gcm solved the issue. I hope google fixes this glitch asap. – tony9099 Aug 25 '13 at 18:49
  • Cool. You can post this as answer and give a link where someone filed this bug. – Shobhit Puri Aug 25 '13 at 19:45
0

Apparently this is a bug from Google's side, which is unsolved until today.

See here.

Reverting back to the old API solved the issue.

tony9099
  • 4,567
  • 9
  • 44
  • 73