Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable Multidex inside flutter which is added to existing android project as module

Tags:

flutter

dart

I have and android project, which I added flutter on it as module, In my original android app, multidex is enabled, but this do not help me, when running the app in debug it's working normally, but when creating a release apk or even debug apk the FlutterFragment is appearing as white, like the engine did not attach.

Things I notice, 'flutter run --release' will ask me to support multidex, and will not run, updating the minSdkVersion to 21 and enabling multidex in .android/app/build.gradle then again 'flutter run --release' works perfect, but this have no effect on the host app because it's under .android which automatically build, and ignored by the host app.

Also I tried to search for how to update minSdkVersion to 21 instead of 16, but references lead to change in the .android which have no effect.

like image 617
Mahmod71 Avatar asked Nov 01 '25 21:11

Mahmod71


1 Answers

Hey you can do two thing

  1. Update your flutter SDK version by running command flutter upgrade The new version of flutter(2.10) multidex support automatically. simply pass the --multidex flag to flutter build appbundle or flutter build apk and your app will support multidex.

2.In your app folder inside android [project_folder]/app/build.gradle and add following lines.

defaultConfig {
...

multiDexEnabled true

}

and

dependencies {
...

implementation 'com.android.support:multidex:1.0.3'
}
like image 101
Ashutosh singh Avatar answered Nov 03 '25 12:11

Ashutosh singh