12

I was trying to set this example: https://code.google.com/p/gcm/source/browse/#git%2Fgcm-client up and running.

The GoogleAPI project has been successfully created, according to the guide: http://developer.android.com/google/gcm/gs.html

However, I have the following problem: on some devices I get SERVICE_NOT_AVAILABLE no matter what.

W/System.err: java.io.IOException: SERVICE_NOT_AVAILABLE W/System.err: at com.google.android.gms.gcm.GoogleCloudMessaging.register(Unknown Source)

Some statistics:

  • Nexus 7, android 4.2.2: GCM example works perfectly
  • Nexus 4, android 4.2: GCM example works perfectly
  • Nexus S, android 4.2.2: GCM example works perfectly
  • Samsung Galaxy 3: SERVICE_NOT_AVAILABLE in 100% cases
  • Samsung Galaxy, android 2.3.6: SERVICE_NOT_AVAILABLE in 100% cases
  • Motorola Xoom, android 4.1.2: SERVICE_NOT_AVAILABLE in 100% cases
  • HTC Desire HD, android 2.3: SERVICE_NOT_AVAILABLE in 100% cases

It's the same code, the same apk file, various google accounts. I tried to switch back to GCMRegistrar methods and they actually work. So the question is: are new GCM methods in sort of beta? How to make them work on other devices, not just 'pure' Google Android devices?

Update: In fact, I found the solution here

Community
  • 1
  • 1
Igor T
  • 512
  • 3
  • 8
  • 12

3 Answers3

3

Sometimes it happened due to time syn with GCM. Please have a look at the time, if it is correct. If possible then reset.

Two more thing to check, if you are using a emulator then please make sure that you have the google api running on the emulator. and second gcm.jar is included on your project.

Shad
  • 1,587
  • 2
  • 20
  • 29
  • I followed the following tutorial to make gcm functional http://www.androidhive.info/2012/10/android-push-notifications-using-google-cloud-messaging-gcm-php-and-mysql/ – Shad Jul 25 '13 at 06:34
  • SYNC was the problem in my case. – DearDhruv Mar 03 '14 at 06:30
2

this is super stupid, but I have same error because I had "restrict app background data" option enabled for google services on my xperia)

orium
  • 3,743
  • 2
  • 24
  • 27
  • I had the same issue! It worked perfectly fine with a wifi connection. But when I tried it with mobile data it didn't work! So it must be something with mobile data settings! So I've disabled "Google Services" 'Restrict background data' and now it works fine :D – Padmal Sep 10 '16 at 02:48
1

Check your phone has an active network connection. I had this issue and then i realized that my test device disconnected from the wifi :)

belphegor
  • 483
  • 7
  • 10