How to Deal With Multidex Issue In Flutter ?

· 3 min read
How to Deal With Multidex Issue In Flutter
How to Deal With Multidex Issue In Flutter

Sometimes when a user runs a project on Android Studio and the user may get an error that states about the multidex issue found in Flutter. So in this article, we will learn about how to deal with the Multidex Issue In Flutter?

How to Deal With Multidex Issue In Flutter?

Follow the below steps to enable multidex for the flutter project.

  • Enable multidex.

Open project/app/build.gradle and add the following lines.

defaultConfig {
    ...

    multiDexEnabled true
}

and

dependencies {
    ...

    implementation 'com.android.support:multidex:1.0.3'
}
  • Enable Jetifier.
  • Open project/android/app/gradle.properties and add the following lines.
    android.useAndroidX=true
    android.enableJetifier=true

    If you’re OK with setting the minimum required Android API level as high as 21 your app will still run on 94.1% of devices as of this writing, then all you have to do is this:

  • Open your “app level build.gradle file” which exists at [your project]\android\app\build.gradle
  •  Change the 16 or whatever number it is for you to a 21:
    defaultConfig {
        // ...
        minSdkVersion 16
        // ...
    }

    to

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

    The default minSDK setting for new Flutter projects is 16, so after adding enough dependencies in pubspec.yaml, many new developers will run into the multidex error and go searching online, potentially getting bogged down in confusing information which only applies to projects with a minimum level set to less than 21.

Conclusion:

In this article, we have learned about How to Solve the Multidex Issue In Flutter ??

Thanks for Reading!!!
Keep Learning.

Do let us know if you need any assistance with Flutter Development?

FlutterAgency.com is our portal Platform dedicated to Flutter Technology and Flutter Developers. The portal is full of cool resources from Flutter like Flutter Widget GuideFlutter ProjectsCode libs and etc.

FlutterAgency.com is one of the most popular online portal dedicated to Flutter Technology and daily thousands of unique visitors come to this portal to enhance their knowledge on Flutter.

Leave a Reply