You should now rely on the official way of doing muti-dexing.
Sample project illustrating how to overcome the 65536 methods dex limitation. Based on the awesome article of @alex_lipov.
To be able to overcome the 65536 methods dex limitation, simply do the following steps :
- Add to your
android
closure inside yourbuild.gradle
:
dexOptions {
preDexLibraries = false
}
- Add the following closure to your
build.gradle
:
afterEvaluate {
tasks.matching {
it.name.startsWith('dex')
}.each { dx ->
if (dx.additionalParameters == null) {
dx.additionalParameters = []
}
dx.additionalParameters += '--multi-dex'
dx.additionalParameters += "--main-dex-list=$projectDir/multidex.keep".toString()
}
}
- Create the file
multidex.keep
in the same folder than thebuild.gradle
with the following content :
android/support/multidex/BuildConfig.class
android/support/multidex/MultiDex$V14.class
android/support/multidex/MultiDex$V19.class
android/support/multidex/MultiDex$V4.class
android/support/multidex/MultiDex.class
android/support/multidex/MultiDexApplication.class
android/support/multidex/MultiDexExtractor$1.class
android/support/multidex/MultiDexExtractor.class
android/support/multidex/ZipUtil$CentralDirectory.class
android/support/multidex/ZipUtil.class
- Add inside your
libs
folder theandroid-support-multidex.jar
located here :ANDROID_HOME/extras/android/support/multidex/library/libs
- If you do not subclassing the Application class, add in your
AndroidManifest.xml
, into theapplication
element, the attributandroid:name="android.support.multidex.MultiDexApplication"
- If you are actually subclassing the Application class, make it extending the
MultiDexApplication
class.
Here you are, you do not have to bother anymore with dex limitation on number of methods. Keep in mind that it will only work on ICS (API 14) and above.
Again, please go read this awesome article of @alex_lipov to get the whole explanation.