Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter enable multiDex for SDK less than 21

How can I enable multiDex for SDK less than 21. This page shows how to do it, but it says for API less 21.

If you do override the Application class, change it to extend MultiDexApplication (if possible) as follows:

public class MyApplication extends MultiDexApplication { ... }

So, in Flutter, my application by default overrides io.flutter.app.FlutterApplication and I should make changes in my FlutterApplication class but I couldn't open this file for editing because it is decompiled version. Can anyone help me? It is an issue on Github


1 Answers

Actually I need to create my own java class say MyApplication.java like this.

public class MyApplication extends FlutterApplication {
    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        MultiDex.install(this);
    }
}

After this in AndroidManifest.xml file, change

<application
    android:name="io.flutter.app.FlutterApplication" .../>

to

<application
    android:name=".MyApplication" .../>

Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!