title: GCM Register SERVICE_NOT_AVAILABLE
body: <p>This is really annoying me. I have an app that uses GCM. I have people complaining they can't login due to an error. Let me show you how I am making the Login:</p>
  
  <pre><code>// Login Activity
  //....
  public void onClickLoginButton (View v) {
  
      // Do some stuff...
  
      new GCMRegister().execute(); //AsyncTask
  }
  
  private class GCMRegister extends AsyncTask&lt;Void, Void, Integer&gt; {
  
      @Override
      protected Integer doInBackground (Void... params) {
          ConnectivityManager connMgr = (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);
          NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();
  
          if (networkInfo != null &amp;&amp; networkInfo.isConnected()) {
              try {
                  //Get GCM Registration key
                  registrationId = googleCloud.register(Settings.PROJECT_NUMBER);
              } catch (Exception e) {
                  Log.e("GCMRegister", e.toString());
                  return -1;
              }
              return 1;
          } else {
              return -3;
          }
      }
  
      @Override
      protected void onPostExecute(Integer result) {
          if (result == 1) {
              new LoginAsync().execute(); // Another AsyncTask to check in my database if user is valid and save its key
          } else {
              user.setEnabled(true);
              password.setEnabled(true);
              login.setEnabled(true);
              if (result == -1) {
                  Toast.makeText(Login.this, "A problem occured login in", Toast.LENGTH_LONG).show();
              } else if (result == -3) {
                  Toast.makeText(Login.this, "I need an internet connection", Toast.LENGTH_LONG).show();
              }
          }
      }
  </code></pre>
  
  <p>So a lot of people is complaining they can't login in because of "A problem occured login" error, which indicates that GCM is failing on register. Even myself with my device, Android 4.4.2, can't do it at first. I need to try to login 2 or 3 times until it works (and Im in a good connection). The error on my LogCat is:</p>
  
  <pre><code>08-04 21:29:10.922: E/GCMRegister(18182): java.io.IOException: SERVICE_NOT_AVAILABLE
  </code></pre>
  
  <p>So what is wrong with my code? This is driving me nuts.</p>