title: Flutter crashes on startup: Didn't find class .MainActivity on path DexPathList
body: <p>I'm using Flutter with the MultiDex builder enabled for Android and encountered a pretty tricky issue. My app was running without any exceptions but when the <code>video_player</code> package was added it just crashed on startup:</p>
  <pre><code>FATAL EXCEPTION: main
  Process: com.rsg.anygoal, PID: 5883
  java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.rsg.anygoal/com.rsg.anygoal.MainActivity}: java.lang.ClassNotFoundException: Didn't find class &quot;com.rsg.anygoal.MainActivity&quot; on path: DexPathList[[zip file &quot;/data/app/com.rsg.anygoal-tCKWlQXJD-iwdHtVRl0qqA==/base.apk&quot;],nativeLibraryDirectories=[/data/app/com.rsg.anygoal-tCKWlQXJD-iwdHtVRl0qqA==/lib/x86, /data/app/com.rsg.anygoal-tCKWlQXJD-iwdHtVRl0qqA==/base.apk!/lib/x86, /system/lib, /vendor/lib]]
      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2679)
      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
      at android.app.ActivityThread.-wrap11(Unknown Source:0)
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
      at android.os.Handler.dispatchMessage(Handler.java:106)
      at android.os.Looper.loop(Looper.java:164)
      at android.app.ActivityThread.main(ActivityThread.java:6494)
      at java.lang.reflect.Method.invoke(Native Method)
      at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
   Caused by: java.lang.ClassNotFoundException: Didn't find class &quot;com.rsg.anygoal.MainActivity&quot; on path: DexPathList[[zip file &quot;/data/app/com.rsg.anygoal-tCKWlQXJD-iwdHtVRl0qqA==/base.apk&quot;],nativeLibraryDirectories=[/data/app/com.rsg.anygoal-tCKWlQXJD-iwdHtVRl0qqA==/lib/x86, /data/app/com.rsg.anygoal-tCKWlQXJD-iwdHtVRl0qqA==/base.apk!/lib/x86, /system/lib, /vendor/lib]]
      at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:125)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
      at android.app.Instrumentation.newActivity(Instrumentation.java:1174)
      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2669)
      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856) 
      at android.app.ActivityThread.-wrap11(Unknown Source:0) 
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589) 
      at android.os.Handler.dispatchMessage(Handler.java:106) 
      at android.os.Looper.loop(Looper.java:164) 
      at android.app.ActivityThread.main(ActivityThread.java:6494) 
      at java.lang.reflect.Method.invoke(Native Method) 
      at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) 
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807) 
  </code></pre>
  <p>Later while investigating the issue I tried to disable MultiDex and that seemingly fixed it, but then adding additional flutter package broke the app again, so I decided it's not strictly caused by multiDex and re-enabled it.</p>
  <p>Another fix attempt I found in forums was to rename <code>&quot;.MainActivity&quot;</code> to the exact class path <code>&quot;com.*...*.MainActivity&quot;</code> but that did not help either.</p>
  <p>Hopefully someone will suggest a possible fix to this! Leaving a few more logs and code snippets I collected during my investigation, which may include clues helpful to you.</p>
  <p><em><strong>Full Android logcat logs: <a href="https://pastebin.com/vPs614jj" rel="noreferrer">https://pastebin.com/vPs614jj</a></strong></em></p>
  <p><em><strong>Flutter pubspec (name and description intentionally omitted):</strong></em></p>
  <pre class="lang-yaml prettyprint-override"><code>version: 1.0.6+16
  environment:
    sdk: &quot;&gt;=2.1.0 &lt;3.0.0&quot;
  
  dependencies:
    flutter:
      sdk: flutter
    cupertino_icons: ^0.1.2
    intl: ^0.15.8
    firebase_core: ^0.4.3+1
    firebase_admob: ^0.9.0+10
    firebase_analytics: ^5.0.9
    firebase_auth: ^0.15.3
    firebase_crashlytics: ^0.1.2+4
    firebase_performance: ^0.3.1+5
    firebase_remote_config: ^0.3.0+1
    firebase_messaging: ^6.0.9
    firebase_dynamic_links: ^0.5.0+9
    cloud_firestore: ^0.13.0+1
    cloud_functions: ^0.4.1+6
    google_sign_in: ^4.1.1
    provider: ^4.0.1
    data_connection_checker: ^0.3.4
    shared_preferences: ^0.5.6
    flutter_markdown: ^0.3.2
    url_launcher: ^5.4.1
    barcode_scan: ^1.0.0
    qr_flutter: ^3.2.0
    share: ^0.6.3+5
    video_player: ^0.10.11+2
  
  dev_dependencies:
    flutter_test:
      sdk: flutter
  
  flutter:
    fonts:
      - family: Raleway
        fonts:
          - asset: fonts/Raleway-Regular.ttf
    uses-material-design: true
  </code></pre>
  <p><em><strong>Android Manifest:</strong></em></p>
  <pre class="lang-xml prettyprint-override"><code>&lt;manifest xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot; package=&quot;$APP_DOMAIN&quot;&gt;
      &lt;application android:name=&quot;io.flutter.app.FlutterApplication&quot; android:label=&quot;$APP_NAME&quot; android:icon=&quot;@mipmap/ic_launcher&quot;&gt;
          &lt;activity android:name=&quot;.MainActivity&quot; android:launchMode=&quot;singleTop&quot; android:theme=&quot;@style/LaunchTheme&quot; android:configChanges=&quot;orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode&quot; android:hardwareAccelerated=&quot;true&quot; android:windowSoftInputMode=&quot;adjustResize&quot;&gt;
              &lt;meta-data android:name=&quot;io.flutter.app.android.SplashScreenUntilFirstFrame&quot; android:value=&quot;true&quot; /&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name=&quot;android.intent.action.MAIN&quot;/&gt;
                  &lt;category android:name=&quot;android.intent.category.LAUNCHER&quot;/&gt;
              &lt;/intent-filter&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name=&quot;FLUTTER_NOTIFICATION_CLICK&quot; /&gt;
                  &lt;category android:name=&quot;android.intent.category.DEFAULT&quot; /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
          &lt;meta-data android:name=&quot;com.google.android.gms.ads.APPLICATION_ID&quot; android:value=&quot;$APP_ADS_ID&quot;/&gt;
          &lt;meta-data
              android:name=&quot;com.google.firebase.messaging.default_notification_icon&quot;
              android:resource=&quot;@drawable/notification_icon&quot; /&gt;
      &lt;/application&gt;
  
      &lt;uses-permission android:name=&quot;android.permission.INTERNET&quot;/&gt;
  &lt;/manifest&gt;
  </code></pre>
  <p><em><strong>MainActivity.java:</strong></em></p>
  <pre class="lang-java prettyprint-override"><code>import android.os.Bundle;
  import io.flutter.app.FlutterActivity;
  import io.flutter.plugins.GeneratedPluginRegistrant;
  
  public class MainActivity extends FlutterActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      GeneratedPluginRegistrant.registerWith(this);
    }
  }
  </code></pre>
  <p><em><strong>Flutter doctor output (XCode shouldn't matter):</strong></em></p>
  <pre><code>Doctor summary (to see all details, run flutter doctor -v):
  [✓] Flutter (Channel stable, v1.17.5, on Mac OS X 10.15.4 19E287, locale en-BG)
   
  [✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
  [!] Xcode - develop for iOS and macOS
      ✗ Xcode installation is incomplete; a full installation is necessary for iOS development.
        Download at: https://developer.apple.com/xcode/download/
        Or install Xcode via the App Store.
        Once installed, run:
          sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
          sudo xcodebuild -runFirstLaunch
  [✓] Android Studio (version 3.5)
  [✓] VS Code (version 1.46.1)
  [✓] Connected device (1 available)
  </code></pre>