Multidex issue with Flutter: Multidex issue while setting up a new project for firestore

Maybe you set up a new application for FireStore and got the following error, mainly due to a Multidex issue in your Flutter app.

Dex: Error converting bytecode to dex:
Cause: com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/internal/zzcew;
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/internal/zzcew;

[... stacktrace omitted for brevity ...]

* What went wrong:
Execution failed for task ':app:transformDexArchiveWithDexMergerForDebug'.
> com.android.build.api.transform.TransformException: com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/internal/zzcew;

No worries I will get you covered.

Multidex issue with Flutter:

This is happening because of some reasons: Multidex issue, where it is not enabled or minSdkVersion is not appropriate

Multidex issue with Flutter

Solution

First Make sure your minSdkVersion is 21 or Above that in the app Level Gridle file: [project_folder]/app/build.gradle

defaultConfig {
            // ...
            minSdkVersion 21
            // ...
}

Then, In the same file [project_folder]/app/build.gradle directory and add the following code inside defaultConfig

defaultConfig {
    //...

    multiDexEnabled true
}

Just Add multiDexEnabled true.

And where it sats dependencies add the following code

dependencies {
    //...

    implementation 'com.android.support:multidex:1.0.3'
}

Next: Go to the [project_folder]/android/gradle.properties and add the following 2 lines

android.useAndroidX=true
android.enableJetifier=true

I Hope this quick fix Solves your issue

Post by: Hemunt Sharma


For more Flutter tutorials, Tips, Tricks, Free code, Questions, and Error Solving.

Remember FlutterDecode.com

Leave a Comment