title: FirebaseInstanceId: background sync failed: SERVICE_NOT_AVAILABLE
body: <p>I am using this tutorial to implement push notifications using Firebase, but I cannot seem to figure it out. Keeps throwing the error: </p>
  
  <pre><code>FirebaseInstanceId: background sync failed: SERVICE_NOT_AVAILABLE, retry in 40s
  </code></pre>
  
  <p>I am created a class extending <code>FirebaseMessagingService</code> and <code>onMessageReceived(..)</code>. I receive the data. I registered the service in the manifest like:</p>
  
  <pre><code> &lt;!-- [START firebase_service] --&gt;
          &lt;service android:name="notifications.MyFirebaseMessagingService"&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="com.google.firebase.MESSAGING_EVENT" /&gt;
              &lt;/intent-filter&gt;
          &lt;/service&gt;
          &lt;!-- [END firebase_service] --&gt;
  </code></pre>
  
  <p>I added latest google-services.json in the root folder of my app. Still, I log nothing.</p>
  
  <p>Naturally, I scoured into StackOverflow to check similar problems. Not many, apparently. Found <a href="https://stackoverflow.com/questions/38583278/android-firebasecouldmessaging-firebaseinstanceid-background-sync-failed-ser">this</a>, but wasn't very helpful as I still got the same message sent. Any thoughts on something I could have missed?</p>
  
  <p>I tried checking if my device has PlayStore services running and indeed it has:</p>
  
  <pre><code>  public boolean isGooglePlayServicesAvailable() {
          GoogleApiAvailability googleApiAvailability = GoogleApiAvailability.getInstance();
          int status = googleApiAvailability.isGooglePlayServicesAvailable(getApplicationContext());
          if (status != ConnectionResult.SUCCESS) {
              if (googleApiAvailability.isUserResolvableError(status)) {
                  googleApiAvailability.getErrorDialog(MainActivity.this, status, 2404).show();
              }
              return false;
          }
          return true;
      }
  </code></pre>