title: @react-native-firebase/messaging error: cannot find symbol FirebaseInstanceId
body: <p>Can't resolve this error in my React Native project, which uses <strong>Firebase Cloud Messaging</strong> module @react-native-firebase/messaging:</p>
  <pre><code>BUILD FAILED in 9s
  
  error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
  Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
  C:\Users\...\node_modules\@react-native-firebase\messaging\android\src\main\java\io\invertase\firebase\messaging\ReactNativeFirebaseMessagingModule.java:34: error: cannot find symbol
  import com.google.firebase.iid.FirebaseInstanceId;
                                ^
    symbol:   class FirebaseInstanceId
    location: package com.google.firebase.iid
  C:\Users\...\node_modules\@react-native-firebase\messaging\android\src\main\java\io\invertase\firebase\messaging\ReactNativeFirebaseMessagingModule.java:121: error: cannot find symbol
        .call(getExecutor(), () -&gt; FirebaseInstanceId.getInstance().getToken(authorizedEntity, scope))
                                   ^
    symbol:   variable FirebaseInstanceId
    location: class ReactNativeFirebaseMessagingModule
  C:\Users\...\node_modules\@react-native-firebase\messaging\android\src\main\java\io\invertase\firebase\messaging\ReactNativeFirebaseMessagingModule.java:135: error: cannot find symbol
          FirebaseInstanceId.getInstance().deleteToken(authorizedEntity, scope);
          ^
    symbol:   variable FirebaseInstanceId
    location: class ReactNativeFirebaseMessagingModule
  3 errors
  
  FAILURE: Build failed with an exception.
  
  * What went wrong:
  Execution failed for task ':react-native-firebase_messaging:compileDebugJavaWithJavac'.
  &gt; Compilation failed; see the compiler error output for details.
  
  * Try:
  Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
  
  * Get more help at https://help.gradle.org
  </code></pre>
  <p>Tried:</p>
  <ul>
  <li>different <strong>gradle</strong> versions 6.9, 7.0, 7.0.1.</li>
  <li>different <strong>google-services</strong> versions 4.3.5, 4.3.6, 4.3.7</li>
  <li>applying <strong>google-services</strong> at the top and at the bottom of build.gradle app</li>
  <li>different <strong>gradle plugin</strong> versions 4.1.3, 4.2.0, 4.2.1</li>
  <li>deleting and reinstalling all node_modules</li>
  <li>cleaning build with <strong>gradlew clean</strong> and rebuilding again after each version change</li>
  </ul>
  <p>Here's my <strong>npm list</strong> output:</p>
  <pre><code>├── @babel/core@7.14.2
  ├── @babel/runtime@7.14.0
  ├── @react-native-community/cli-platform-android@5.0.1-alpha.1
  ├── @react-native-community/eslint-config@2.0.0
  ├── @react-native-firebase/analytics@11.5.0
  ├── @react-native-firebase/app@11.5.0
  ├── @react-native-firebase/crashlytics@11.5.0
  ├── @react-native-firebase/functions@11.5.0
  ├── @react-native-firebase/messaging@11.5.0
  ├── babel-jest@26.6.3
  ├── eslint@7.26.0
  ├── fast-html-parser@1.0.1
  ├── jest@26.6.3
  ├── metro-react-native-babel-preset@0.66.0
  ├── react-native-keep-awake@4.0.0
  ├── react-native-mmkv-storage@0.5.8
  ├── react-native-print@0.7.0
  ├── react-native-sound-player@0.10.8
  ├── react-native-webview@11.4.4
  ├── react-native@0.64.1
  ├── react-test-renderer@17.0.2
  ├── react@17.0.2
  └── util@0.12.3
  </code></pre>
  <p>I'm overriding to latest firebase BOM 28.0.1. Also tried default @react-native-firebase 26.8.0 version, then app crashes on start with no error output at build or metro.
  App has <strong>google-services.json</strong> at android/app and is registered in firebase.
  Currently using gradle 6.9, plugin 4.1.3, and google-services 4.3.5.</p>
  <p>First time the messaging is used at index.js, listening for background push messages, as stated in docs at <a href="https://rnfirebase.io/messaging/usage" rel="nofollow noreferrer">https://rnfirebase.io/messaging/usage</a>:</p>
  <pre><code>import {AppRegistry} from 'react-native';
  import App from './App';
  import {name as appName} from './app.json';
  import messaging from '@react-native-firebase/messaging';
  
  // Register background handler
  messaging().setBackgroundMessageHandler(async (remoteMessage) =&gt; {
    console.log('Message handled in the background!', remoteMessage);
  });
  
  AppRegistry.registerComponent(appName, () =&gt; App);
  </code></pre>
  <p>Later try to get device token and call cloud function:</p>
  <pre><code> var switchFunction = functions().httpsCallable(toggleFunctionName);
    messaging()
      .getToken()
      .then((token) =&gt; {
        switchFunction({
          organization: encodeURI(parsedLocalData.organizationName),
          user_email: encodeURI(parsedLocalData.userMai),
          device_token: token,
        })
          .then((result) =&gt; {
            // Read result of the Cloud Function.
            var sanitizedMessage = result.data.text;
            console.log('Firebase: ' + sanitizedMessage);
          })
          .catch((error) =&gt; {
            // Getting the Error details.
            console.log('Firebase error: ' + error);
          });
      });
  </code></pre>