6

can anyone tell me if multi dex is supported in android 2.3?

I've searched around but i can't find information for this. My project have the same configuration like this one: https://github.com/mustafa01ali/MultiDexTest

The project builds without problem, but the final apk can't be installed in devices with 2.3 or lower.

On installation I get the error

Failure [INSTALL_FAILED_DEXOPT]

in Android Studio and this appears in logcat:

E/dalvikvm﹕ LinearAlloc exceeded capacity (5242880), last=1384
W/installd﹕ DexInv: --- END '/data/app/xxx.apk' --- status=0x000b, process failed
E/installd﹕ dexopt failed on '/data/dalvik-cache/data@app@xxx.apk@classes.dex' res = 11
Scott Barta
  • 79,344
  • 24
  • 180
  • 163
Zasuk
  • 750
  • 1
  • 7
  • 14
  • 1
    Please Google this. This is officially supported: https://plus.google.com/+IanLake/posts/JW9x4pcB1rj. MultiDex: http://developer.android.com/reference/android/support/multidex/MultiDexApplication.html. – Jared Burrows Dec 03 '14 at 17:36
  • Thanks Jared. Can you tell me if when Ian Lake says "all API 4+ devices" he is talking about api level or android version? Android 4.0 have an api level 14... – Zasuk Dec 03 '14 at 17:46
  • 1
    Re-read what you just asked me. API 4+ is API 4 and greater than 4. Please read: http://developer.android.com/reference/android/support/multidex/MultiDex.html. – Jared Burrows Dec 03 '14 at 17:51
  • 1
    sorry, it has a tough day digging around to fix this. My project with "multiDexEnabled true" compiled with Android Studio RC2 and build tools 21.1.1 always fails to install the apk in devices with 2.3. I've tried some examples that i found on github and they also have the same problem. Maybe some bug in build tools?! i really don't know what i'm missing to make this work. – Zasuk Dec 03 '14 at 18:01
  • 1
    Can you post your build.gradle? What version is your android gradle plugin? – Jared Burrows Dec 03 '14 at 18:03
  • What's the error message when you're trying to install on 2.3? – Scott Barta Dec 03 '14 at 18:09
  • I'm using the last version of the plugin. You can use the github project in my question as an example. i just get "Failure [INSTALL_FAILED_DEXOPT]" in android studio. And in logcat i have http://pastebin.com/LNnjFwCY – Zasuk Dec 03 '14 at 18:24
  • i think there is a new version of android gradle plugin...just a second and i will try it. – Zasuk Dec 03 '14 at 18:28
  • it has the android gradle plugin. the app installs but i have a crash "Multi dex installation failed". I will try to fix it and report here. Thanks – Zasuk Dec 03 '14 at 19:00
  • Get the same error. It is working in Jellybean but failed on Ginerbread. – neobie Apr 09 '16 at 12:52

1 Answers1

5

You're hitting a different size limitation (LinearAlloc), which according to this bug is not solved by multi-dex:

https://code.google.com/p/android/issues/detail?id=78035

From comment #7 in that bug:

There is already an option in dx allowing to force generation of smaller dex files: --set-max-idx-number= Unfortunately changing the default is not a solution since the linearAlloc limit can be reached at very different levels depending on the classes hierarchy and other criteria.

In addition for most applications, moving to multidex will only help to workaround the linearalloc limit for the installation. But the application will still crash against the same limit at execution. The only working use case where I know multidex can help with linearalloc is when the apk does not contains one application but distinct pieces running in separate process.

It's not clear that there's anything you can do to work around this limit, at least in the long term; you may need to simplify your app. There's another StackOverflow question here with some information and some workarounds that may get you up and running, at least for a while:

How to avoid LinearAlloc Exceeded Capacity error android

Community
  • 1
  • 1
Scott Barta
  • 79,344
  • 24
  • 180
  • 163