If you don't have experience with developing android application this information can be helpful otherwise you won't find anything new.
In most cases, enough will do the first step
How to enable multidex for flutter project.
- Enable multidex.
Open [project_folder]/app/build.gradle
and add following lines.
defaultConfig {
...
multiDexEnabled true
}
and
dependencies {
...
implementation 'com.android.support:multidex:1.0.3'
}
- Enable Jetifier.
Open [project_folder]/android/app/gradle.properties
and add following lines.
android.useAndroidX=true
android.enableJetifier=true
NOTE: As of flutter 1.7, the below steps are no longer necessary.
3) **Create custom application class.**
If you don't know where to create the file do it near MainActivity
for example [project_folder]/android/app/src/main/kotlin(or java if you didn't enable kotlin)/your/great/pakage/appname/
kotlin example: App.kt
package your.great.pakage.appname
import io.flutter.app.FlutterApplication
import android.content.Context
import androidx.multidex.MultiDex
class App : FlutterApplication() {
override fun attachBaseContext(base: Context) {
super.attachBaseContext(base)
MultiDex.install(this)
}
}
java example: App.java
package your.great.pakage.appname;
import io.flutter.app.FlutterApplication;
import android.content.Context;
import androidx.multidex.MultiDex;
public class App extends FlutterApplication {
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}
- Change the default application file to new.
Open [project_folder]/android/app/src/main/AndroidManifest.xml
Change android:name="io.flutter.app.FlutterApplication"
to android:name=".App"
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…