title: How to fix " :react-native-firebase:compileDebugJavaWithJavac FAILED" + cannot find import com.google.firebase.iid.FirebaseInstanceIdService;
body: <p>Recently I cloned a new project and tried to <code>react-native run-android</code>
  Unfortunately for some reasons, I can't run my project and the terminal shows me this error: <code>&gt; Task :react-native-firebase:compileDebugJavaWithJavac FAILED</code>, and above this Err I saw more info about this in detail => 'can not find symbol import com.google.firebase.iid.FirebaseInstanceIdService;'.</p>
  
  <p>I searched this issue a lot and I found out that "FirebaseInstanceIdService" is deprecated so I should comment <code>import com.google.firebase.iid.FirebaseInstanceIdService;</code> in InstanceIdService.java located in => <code>\node_modules\react-native-fcm\android\src\main\java\com\evollu\react\fcm\InstanceIdService.java</code>, besides I should make some other changes too. but again I receieve  the same error.</p>
  
  <p>The content of InstanceIdService.java (before making any changes):</p>
  
  <pre><code>package com.evollu.react.fcm;
  
  import android.content.Intent;
  import android.os.Bundle;
  import android.os.Handler;
  import android.os.Looper;
  import android.support.v4.content.LocalBroadcastManager;
  import android.util.Log;
  
  import com.facebook.react.ReactApplication;
  import com.facebook.react.ReactInstanceManager;
  import com.facebook.react.bridge.ReactContext;
  import com.google.firebase.iid.FirebaseInstanceId;
  import com.google.firebase.iid.FirebaseInstanceIdService;
  
  public class InstanceIdService extends FirebaseInstanceIdService {
  
      private static final String TAG = "InstanceIdService";
  
      /**
       * Called if InstanceID token is updated. This may occur if the security of
       * the previous token had been compromised. This call is initiated by the
       * InstanceID provider.
       */
      // [START refresh_token]
      @Override
      public void onTokenRefresh() {
          // Get updated InstanceID token.
          String refreshedToken = FirebaseInstanceId.getInstance().getToken();
          Log.d(TAG, "Refreshed token: " + refreshedToken);
  
          // Broadcast refreshed token
          Intent i = new Intent("com.evollu.react.fcm.FCMRefreshToken");
          Bundle bundle = new Bundle();
          bundle.putString("token", refreshedToken);
          i.putExtras(bundle);
  
          final Intent message = i;
  
          Handler handler = new Handler(Looper.getMainLooper());
          handler.post(new Runnable() {
              public void run() {
                  // Construct and load our normal React JS code bundle
                  ReactInstanceManager mReactInstanceManager = ((ReactApplication) getApplication()).getReactNativeHost().getReactInstanceManager();
                  ReactContext context = mReactInstanceManager.getCurrentReactContext();
                  // If it's constructed, send a notification
                  if (context != null) {
                      LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(message);
                  } else {
                      // Otherwise wait for construction, then send the notification
                      mReactInstanceManager.addReactInstanceEventListener(new ReactInstanceManager.ReactInstanceEventListener() {
                          public void onReactContextInitialized(ReactContext context) {
                              LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(message);
                          }
                      });
                      if (!mReactInstanceManager.hasStartedCreatingInitialContext()) {
                          // Construct it in the background
                          mReactInstanceManager.createReactContextInBackground();
                      }
                  }
              }
          });
      }
  }
  
  </code></pre>
  
  <p>The content of edited InstanceIdService.java:</p>
  
  <pre><code>package com.evollu.react.fcm;
  
  import android.content.Intent;
  import android.os.Bundle;
  import android.os.Handler;
  import android.os.Looper;
  import android.support.v4.content.LocalBroadcastManager;
  import android.util.Log;
  
  import com.facebook.react.ReactApplication;
  import com.facebook.react.ReactInstanceManager;
  import com.facebook.react.bridge.ReactContext;
  import com.google.firebase.iid.FirebaseInstanceId;
  //import com.google.firebase.iid.FirebaseInstanceIdService; //Commented FirebaseInstanceIdService
  import com.google.firebase.messaging.FirebaseMessagingService;  //ADD FirebaseMessagingService
  
  // public class InstanceIdService extends FirebaseMessagingService {
  public class MyFireBaseInstanceIDService  extends FirebaseMessagingService {
  
      private static final String TAG = "InstanceIdService";
      // private static final String TAG = MyFireBaseInstanceIDService.class.getSimpleName();;
  
      /**
       * Called if InstanceID token is updated. This may occur if the security of
       * the previous token had been compromised. This call is initiated by the
       * InstanceID provider.
       */
      // [START refresh_token]
      @Override
      public void onNewToken(String token) { //Added onNewToken method
          // Get updated InstanceID token.
          String refreshedToken = FirebaseInstanceId.getInstance().getToken();
          Log.d(TAG, "Refreshed token: " + refreshedToken);
  
          // Broadcast refreshed token
          Intent i = new Intent("com.evollu.react.fcm.FCMRefreshToken");
          Bundle bundle = new Bundle();
          bundle.putString("token", refreshedToken);
          i.putExtras(bundle);
  
          final Intent message = i;
  
          Handler handler = new Handler(Looper.getMainLooper());
          handler.post(new Runnable() {
              public void run() {
                  // Construct and load our normal React JS code bundle
                  ReactInstanceManager mReactInstanceManager = ((ReactApplication) getApplication()).getReactNativeHost().getReactInstanceManager();
                  ReactContext context = mReactInstanceManager.getCurrentReactContext();
                  // If it's constructed, send a notification
                  if (context != null) {
                      LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(message);
                  } else {
                      // Otherwise wait for construction, then send the notification
                      mReactInstanceManager.addReactInstanceEventListener(new ReactInstanceManager.ReactInstanceEventListener() {
                          public void onReactContextInitialized(ReactContext context) {
                              LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(message);
                          }
                      });
                      if (!mReactInstanceManager.hasStartedCreatingInitialContext()) {
                          // Construct it in the background
                          mReactInstanceManager.createReactContextInBackground();
                      }
                  }
              }
          });
      }
  }
  </code></pre>
  
  <p><strong>Please Note That:</strong> I have the same problem both in <code>react-native-fcm</code> and <code>react-native-firebase</code> it seems I should make some changes in '<code>RNFirebaseInstanceIdService.java</code>' and '<code>RNFirebasePerformance.java</code>'</p>
  
  <p><strong>JUST ADDED THIS NOTE AFTER I SOLVED THE ISSUE MYSELF::</strong>
  it wasn't about react-native-fcm at all! it was all about react-native-firebase as I said before 'Although the deprecated 'instanceIdService' does exist in react-native-fcm which once I've tried to make some changes.</p>
  
  <p>Thanks</p>