title: Flutter: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/firebase/iid/FirebaseInstanceId
body: <p>SDK: Flutter</p>
  <p>We are using Flutter with Firebase messaging in our app. Along with it, we are using plain_notification_token to get the FCM Token for Android and APNS Token for iOS. Getting this error when upgrading Gradle to 4.2.2.</p>
  <p><strong>Issue</strong></p>
  <pre><code>E/AndroidRuntime(27480):    at net.kikuchy.plain_notification_token.PlainNotificationTokenPlugin.onMethodCall(PlainNotificationTokenPlugin.java:47)
  E/AndroidRuntime(27480):    at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
  E/AndroidRuntime(27480):    at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
  E/AndroidRuntime(27480):    at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:818)
  E/AndroidRuntime(27480):    at android.os.MessageQueue.nativePollOnce(Native Method)
  E/AndroidRuntime(27480):    at android.os.MessageQueue.next(MessageQueue.java:335)
  E/AndroidRuntime(27480):    at android.os.Looper.loop(Looper.java:183)
  E/AndroidRuntime(27480):    at android.app.ActivityThread.main(ActivityThread.java:8010)
  E/AndroidRuntime(27480):    at java.lang.reflect.Method.invoke(Native Method)
  E/AndroidRuntime(27480):    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:631)
  E/AndroidRuntime(27480):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:978)
  E/AndroidRuntime(27480): Caused by: java.lang.ClassNotFoundException: Didn't find class &quot;com.google.firebase.iid.FirebaseInstanceId&quot; on path: DexPathList[[zip file &quot;/data/app/~~5gcFVfnQoOUOHN3V15pnZA==/money.bullet.internal-fy-pjwoLC9rHFRqMpeWWJw==/base.apk&quot;],nativeLibraryDirectories=[/data/app/~~5gcFVfnQoOUOHN3V15pnZA==/money.bullet.internal-fy-pjwoLC9rHFRqMpeWWJw==/lib/arm64, /data/app/~~5gcFVfnQoOUOHN3V15pnZA==/money.bullet.internal-fy-pjwoLC9rHFRqMpeWWJw==/base.apk!/lib/arm64-v8a, /system/lib64, /system/system_ext/lib64]]
  E/AndroidRuntime(27480):    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:207)
  E/AndroidRuntime(27480):    at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
  E/AndroidRuntime(27480):    at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
  E/AndroidRuntime(27480):    ... 11 more
  I/Process (27480): Sending signal. PID: 27480 SIG: 9
  Lost connection to device.
  </code></pre>
  <p><strong>Android/app/build.gradle</strong></p>
  <pre><code>dependencies {
      implementation fileTree(dir: &quot;libs&quot;, include: [&quot;*.jar&quot;, &quot;*.aar&quot;])
      implementation &quot;org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version&quot;
      implementation 'com.google.code.gson:gson:2.8.6'
      implementation 'androidx.core:core:1.6.0'
      implementation 'androidx.fragment:fragment:1.3.5'
      implementation &quot;com.clevertap.android:clevertap-android-sdk:4.1.1&quot;
      implementation 'com.google.android.play:core:1.10.0'
      implementation 'com.google.android.gms:play-services-basement:17.6.0'
  
      //MANDATORY for App Inbox
      implementation 'androidx.appcompat:appcompat:1.3.0'
      implementation 'androidx.recyclerview:recyclerview:1.2.1'
      implementation 'androidx.viewpager:viewpager:1.0.0'
      implementation 'com.google.android.material:material:1.4.0'
      implementation 'com.github.bumptech.glide:glide:4.11.0'
  
      //For CleverTap Android SDK v3.6.4 and above add the following -
      implementation 'com.android.installreferrer:installreferrer:2.2'
  
      //Optional ExoPlayer Libraries for Audio/Video Inbox Messages. Audio/Video messages will be dropped without these dependencies
      implementation 'com.google.android.exoplayer:exoplayer:2.14.1'
      implementation 'com.google.android.exoplayer:exoplayer-hls:2.14.1'
      implementation 'com.google.android.exoplayer:exoplayer-ui:2.14.1'
      implementation 'com.google.firebase:firebase-messaging:22.0.0'
  
      // For bureau-sdk to get the advertising-id
      implementation 'com.google.android.gms:play-services-ads-identifier:17.0.1'
  //    implementation 'com.google.firebase:firebase-iid'
  }
  
  apply plugin: 'com.google.gms.google-services'
  apply plugin: 'com.google.firebase.crashlytics'
  apply plugin: 'com.google.firebase.firebase-perf'
  
  googleServices { disableVersionCheck = true }
  </code></pre>
  <p>This is the build.gradle file where after updating the Gradle version to 4.2.2 from 3.x, the issue started coming up in Flutter project. I am able to compile the App but the App crashes at Runtime.</p>
  <p><strong>build.gradle</strong></p>
  <pre><code>buildscript {
      ext.kotlin_version = '1.5.20'
      repositories {
          google()
          mavenCentral()
      }
  
      dependencies {
          classpath 'com.android.tools.build:gradle:4.2.2'
          classpath &quot;org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version&quot;
          classpath 'com.google.gms:google-services:4.3.8'
          classpath 'com.google.firebase:firebase-crashlytics-gradle:2.7.1'
          classpath 'com.google.firebase:perf-plugin:1.4.0'
      }
  }
  
  allprojects {
      repositories {
          google()
          mavenCentral()
      }
      configurations.all {
          resolutionStrategy {
              forcedModules = [
                      &quot;com.google.android.gms:play-services-vision-common:19.0.2&quot;,
              ]
          }
      }
  }
  
  rootProject.buildDir = '../build'
  subprojects {
      project.buildDir = &quot;${rootProject.buildDir}/${project.name}&quot;
  }
  subprojects {
      project.evaluationDependsOn(':app')
  }
  
  task clean(type: Delete) {
      delete rootProject.buildDir
  }
  
  </code></pre>