How to fix Google Cloud Messaging Registration error: SERVICE_NOT_AVAILABLE?

MainstreamDeveloper00 picture MainstreamDeveloper00 · Jun 19, 2013 · Viewed 76.9k times · Source

I encountered a strange problem - I've been using GCM in my application for quite a long time and everything works perfectly. However, before a release to Google Play I changed my application package name from com.android.testapp to com.android.recognition and after this GCM stopped working. At first I got en error GCM sender id not set on constructor and fixed it by overriding getSenderIds(Context context), but now I can't get a registration ID. Here are the messages from logcat: enter image description here

How can I fix this? When I switched to a new package I changed everything in the manifest file to the new package:

<receiver
        android:name="com.google.android.gcm.GCMBroadcastReceiver"
        android:permission="com.google.android.c2dm.permission.SEND" >
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />
            <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
            <category android:name="com.android.recognition" />
        </intent-filter>
    </receiver>

So what is the problem behind this? Can renaming the application package cause this or is there another reason?

Answer

Aman Gautam picture Aman Gautam · Dec 21, 2013

The problem is answered, in my case it was little more complicated.

  1. Check you have an active internet connection
  2. Check that you have Internet permission in your manifest
  3. Make sure the package name is correct as Eran mentioned
  4. The device time is correctly setup. Even if everything is perfect, it will fail if device clock is not set correctly.

Wrong clock caused problem for me. :)