Skip to content

No more headache with Multidex; Get rid of maintaining the mainDexList.txt now

License

Notifications You must be signed in to change notification settings

hacktons/dexing

Repository files navigation

Dexing

Maven Central github License Apache Build Status

When your app and the libraries it references exceed 65,536 enmethods, we need to ship apk with multidex enable, usually follow the guides: Enable multidex for apps with over 64K methods.

However the main dex classes.dex can still be too large; It' difficult to maintain the mainDexList.txt since your app's keep growing.

What's more, the gradle task for multidex can changes too, that may break our task hook.

The dexing library can help you get rid of maintaining the mainDexList.txt,since we've minimize the classes needed before multidex and optdex:

multidex

How to use

1.Add dependence to dexing aar:

implementation 'com.github.avenwu:dexing:$latest_version'

2.Install dex in application:

The install api is same as multidex support library:

import cn.hacktons.dexing.Multidex;

public class CustomApplication extends Application {
    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        Multidex.install(this);
    }
}

3.Keep rule Make sure the dexing package is included in main dex. If not, add this rule into your dex keep list:

# multidex-config.pro
-keep class cn.hacktons.dexing.**
multiDexKeepProguard file('multidex-config.pro')

Advance

We've provided a Activity with simple loading process bar when dex is installing. You may replace the loading layout through the second parameter of Multidex.install:

Multidex.install(this, R.layout.custom_loading);

If there are ClassNotFoundException, keep missing class in the multiDexKeepProguard file as Enable multidex for apps with over 64K methods mentioned.

Debug

If dex installation doest work well, you can enable logging to see the whole process:

// enable log
Multidex.enableLog();
Multidex.install(this);

Here are some example logs, including main process and :nodex process.

main-process-log

nodex-process-log

About

No more headache with Multidex; Get rid of maintaining the mainDexList.txt now

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published