Android Multidex Support Library Using Eclipse

Android multidex support library using eclipse

It looks like ADT's ant-tasks project is no longer maintained (it resides under 'legacy' folder).

So if you can't migrate to Gradle, you can edit the DexExecTask manually. You'll have of course to rebuild the project locally..

[Edit - 10/25/2014] maven-android-plugin does support multi-dex. However, it currently has a small issue: secondary dex files placed in wrong location. This pull request strives to fix that, so stay tuned! (Fixed in 4.0.0)

Enabling MultiDex Support in Android to achieve 65K+ methods in Eclipse

You have to modify build.gradle to add multiDexEnabled true under buildconfig, buildType or productFlavour sections

defaultConfig {
// The support library goes as back as Android-14, and is not required for 21+
minSdkVersion 14

// Enabling multidex support.
multiDexEnabled true
}

If you're building on old Ant, this is a blocking problem so you'll have to move to gradle or maven or use the old cumbersome solution

http://android-developers.blogspot.com.es/2011/07/custom-class-loading-in-dalvik.html

android-support-multidex.jar not working in eclipse

Possible duplicate here. Answer from Alex Lipov:

It looks like ADT's ant-tasks project is no longer maintained (it
resides under 'legacy' folder). So if you can't migrate to Gradle,
you can edit the DexExecTask manually. You'll have of course to
rebuild the project locally..

[Edit - 10/25/2014] maven-android-plugin does support multi-dex. However, it currently has a small issue: secondary dex
files placed in wrong location. This pull request strives to fix
that, so stay tuned!

Eclipse to Android Studio Import

I suspect your dex error is a result of the growth of a library, but without more info, this is hard to debug. The newest version of Android Studio (2.2) provides an APK analyzer tool that makes the dex limit more transparent.

When using Google Play services APIs you should double check to make sure that you're only including the ones used with these directives
compile 'com.google.android.gms:play-services-fitness:9.6.1'
rather than including everything (full list).

If you need all the libraries you're already depending on then, this is typically resolved by enabling multidex in your development environment (requiring development using a device or emulator with L or greater), but then using minificationEnabled in your release builds such that multidex isn't required in your release APK. This results in a combination of fast debug builds and non-multidex your release builds to prevent slow startup times for your release build.

A bit more info:
When you use native multidex in debug builds (requires minSdk set to L or greater) it results in faster incremental builds because modules and libraries deploy as separate dex files and less processing between deploys.

When you use minificationEnabled in your release build it often eliminates the need for the second dex file because methods from your dependendencies that you don't use are trimmed. This typically results in a single dex nullifying the negative effects of multidex (copying the N+1 dex files on app initialization for < version L devices).



Related Topics



Leave a reply



Submit