title: Android GCM error. Server returns Not Registered when client IS registered
body: <p>I followed the demo given at <a href="http://developer.android.com/google/gcm/gs.html" rel="noreferrer">http://developer.android.com/google/gcm/gs.html</a> and got a trial application, GCMTrial to work correctly. </p>
  
  <p>But, i tried to follow the same steps on an existing application but it didnot work. So I made an entirely new project. But even then , following the same exact steps, I couldnt get GCM to send a message successfully. So I tried renaming GCMTrial to the required name, and not that too does not work.</p>
  
  <p>I register for GCM via the main activity and get the following log :</p>
  
  <pre><code>12-19 21:30:13.102: V/GCMRegistrar(15889): Registering receiver
  12-19 21:30:13.112: D/GCMBaseIntentService(15889): handleRegistration: registrationId =         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX, error = null, unregistered = null
  12-19 21:30:13.112: D/GCMRegistrar(15889): resetting backoff for com.XXX.XXX
  12-19 21:30:13.117: V/GCMRegistrar(15889): Saving regId on app version 1
  </code></pre>
  
  <p>But when i try to send a GCM message, it returns the following error</p>
  
  <pre><code>[ errorCode=NotRegistered ]
  </code></pre>
  
  <p>Client Code : </p>
  
  <pre><code>public class MainActivity extends Activity {
  TextView tve;
  String TAG = "GCMTrial";
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      GCMRegistrar.checkDevice(this);
      GCMRegistrar.checkManifest(this);
      final String regId = GCMRegistrar.getRegistrationId(this);
      if (regId.equals("")) {
          GCMRegistrar.register(this, "XXXXXX");
          Log.v(TAG, "Reg");
      } else {
          Log.v(TAG, "Already registered");
      }
  }
  
  GCMIntentService : 
  public class GCMIntentService extends GCMBaseIntentService {
  @Override
  protected void onError(Context arg0, String arg1) {
      // TODO Auto-generated method stub
  }
  @Override
  protected void onMessage(Context arg0, Intent arg1) {
      // TODO Auto-generated method stub
      Log.d("GCM", "RECIEVED A MESSAGE");
      // Get the data from intent and send to notificaion bar
  }
  @Override
  protected void onRegistered(Context arg0, String arg1) {
      // TODO Auto-generated method stub
  }
  @Override
  protected void onUnregistered(Context arg0, String arg1) {
      // TODO Auto-generated method stub
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Manifest : 
      
      
          
          
          
          
          
          
          
          
          
              
                  
                  
              
          
          
              
                  
                  
                  
              
          
          
      
      </p>
  
  <p>Server Code : </p>
  
  <pre><code>System.out.println("Sending GCM");
      String key = "XXX"; //Server API key taken from the site
      clientID = "XXXXXXXXX"; // copied from the logs
      Sender sender = new Sender(key);
      Message message = new Message.Builder().build();
      Result result = sender.send(message, clientID, 1);
      System.out.println(result.toString());
  </code></pre>
  
  <p>It is driving me crazy.. It shows as registered in the android phone, even calls the onRegistered method of the GCMIntentService class.. but when i try to send a message, it flags a "NotRegistered Error" ...
  I dont know what im doing wrong.. please help me out guys....</p>