My flutter app is crashing the moment it launches with the following error:

Issue

After the app launches and exists instantly, the console says the following error:

I searched many solutions her and there but could not figure out anything.

Help is really appreciated. BTW, this is the only thing that is preventing me from releasing my app and publishing it. Thanks alot.

√ Built build\app\outputs\flutter-apk\app-debug.apk.
Installing build\app\outputs\flutter-apk\app.apk...
E/AndroidRuntime(13552): FATAL EXCEPTION: main
E/AndroidRuntime(13552): Process: com.comet.manga, PID: 13552
E/AndroidRuntime(13552): java.lang.RuntimeException: Unable to instantiate application com.comet.manga.Application: java.lang.ClassNotFoundException: Didn't find class "com.comet.manga.Application" on path: DexPathList[[zip file "/data/app/com.comet.manga-3NMRdDTvHVRYO7itAb__EQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.comet.manga-3NMRdDTvHVRYO7itAb__EQ==/lib/x86, /data/app/com.comet.manga-3NMRdDTvHVRYO7itAb__EQ==/base.apk!/lib/x86, /system/lib, /system/product/lib]]
E/AndroidRuntime(13552):    at android.app.LoadedApk.makeApplication(LoadedApk.java:1226)
E/AndroidRuntime(13552):    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6431)
E/AndroidRuntime(13552):    at android.app.ActivityThread.access$1300(ActivityThread.java:219)
E/AndroidRuntime(13552):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1859)
E/AndroidRuntime(13552):    at android.os.Handler.dispatchMessage(Handler.java:107)
E/AndroidRuntime(13552):    at android.os.Looper.loop(Looper.java:214)
E/AndroidRuntime(13552):    at android.app.ActivityThread.main(ActivityThread.java:7356)
E/AndroidRuntime(13552):    at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(13552):    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
E/AndroidRuntime(13552):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
E/AndroidRuntime(13552): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.comet.manga.Application" on path: DexPathList[[zip file "/data/app/com.comet.manga-3NMRdDTvHVRYO7itAb__EQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.comet.manga-3NMRdDTvHVRYO7itAb__EQ==/lib/x86, /data/app/com.comet.manga-3NMRdDTvHVRYO7itAb__EQ==/base.apk!/lib/x86, /system/lib, /system/product/lib]]
E/AndroidRuntime(13552):    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:196)
E/AndroidRuntime(13552):    at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
E/AndroidRuntime(13552):    at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
E/AndroidRuntime(13552):    at android.app.AppComponentFactory.instantiateApplication(AppComponentFactory.java:76)
E/AndroidRuntime(13552):    at androidx.core.app.CoreComponentFactory.instantiateApplication(CoreComponentFactory.java:52)
E/AndroidRuntime(13552):    at android.app.Instrumentation.newApplication(Instrumentation.java:1148)
E/AndroidRuntime(13552):    at android.app.LoadedApk.makeApplication(LoadedApk.java:1218)
E/AndroidRuntime(13552):    ... 9 more

Solution

I think your error is due to Dex Error,it can be resolved by enabling multiDex. So in your android/app directory add these lines to the build.gradle file:

android {
    defaultConfig {
        ...
        multiDexEnabled true
    }
}

dependencies {
  implementation 'com.android.support:multidex:1.0.3'
  ....

Answered By – Payam Asefi

Answer Checked By – Clifford M. (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published.