Indeed our main-dex classes list is too big (amount of methods is greater than 65k). I'm currently checking what are the options in this situation. The simple one will be to revert to our pre-multidex solution, even though it is very painful.
I have one more question regarding multidex. Why Activities are configured as roots for main dex file? I can understand why Application (and all its direct reference hierarchy) class has to be there, since it is loaded and verified before the ClassLoader patching. But why Activities? Just to test that, I created a test app <https://github.com/alipov/multidex-test> that uses --minimal-main-dex flag, and its main-dex list includes only the android.support.multidex classes. This app has a main activity, which is (according to configuration) packaged into a second dex. Everything works well, which makes me wonder why in android-gradle-plugin activities are configured as main-dex roots.. Could you please elaborate on this? -Alex On Sunday, November 16, 2014 8:33:18 PM UTC+2, Xavier Ducrohet wrote: > > Can you look in D:\x\y\build\intermediates\multi-dex\debug\maindexlist.txt > and count the number of classes? > > We added --set-max-idx-number=60000 to work around some problem on much > older platforms (Gingerbread), but this is independent from the computation > of the main dex list (and one is methods and the other classes) > > You could get into a situation where the required list of classes for the > main dex list is too big for one dex, in which case it just won't work. > > On Sun, Nov 16, 2014 at 9:34 AM, Alex Lipov <[email protected] > <javascript:>> wrote: > >> After upgrading to version 0.14.2 of Gradle plugin, I'm receiving the >> following error during the dx task: >> >> > com.android.ide.common.internal.LoggedErrorException: Failed to run >> command: >> C:\bin\sdk\build-tools\21.1.0\dx.bat -JXmx4g --dex --force-jumbo >> --multi-dex --main-dex-list >> D:\x\y\build\intermediates\multi-dex\debug\maindexlist.txt >> --set-max-idx-number=60000 --output D:\x\y\build\intermediates\dex\debug >> --input-list=D:\x\y\build\intermediates\tmp\dex\debug\libraryList.txt >> Error Code: >> 2 >> Output: >> UNEXPECTED TOP-LEVEL EXCEPTION: >> com.android.dex.DexException: Too many classes in --main-dex-list, main >> dex capacity exceeded >> at com.android.dx.command.dexer.Main.processAllFiles(Main.java:494) >> at com.android.dx.command.dexer.Main.runMultiDex(Main.java:332) >> at com.android.dx.command.dexer.Main.run(Main.java:243) >> at com.android.dx.command.dexer.Main.main(Main.java:214) >> at com.android.dx.command.Main.main(Main.java:106) >> >> Attaching some dex statistics as well: >> annotation: 2853 items; 52698 bytes total >> 4..406 bytes/item; average 18 >> annotation set: 2652 items; 28340 bytes total >> 4..28 bytes/item; average 10 >> annotation set ref list: 23 items; 268 bytes total >> 8..20 bytes/item; average 11 >> annotations directory: 1911 items; 55808 bytes total >> 16..784 bytes/item; average 29 >> class data: 2606 items; 267584 bytes total >> 9..6687 bytes/item; average 102 >> class def: 2686 items; 85952 bytes total >> 32 bytes/item >> code: 21150 items; 2589324 bytes total >> 20..27328 bytes/item; average 122 >> debug info: 21127 items; 561607 bytes total >> 5..2189 bytes/item; average 26 >> encoded array: 601 items; 169167 bytes total >> 2..16682 bytes/item; average 281 >> field id: 55438 items; 443504 bytes total >> 8 bytes/item >> header: 1 item; 112 bytes total >> 112 bytes/item >> map list: 1 item; 220 bytes total >> 220 bytes/item >> method id: 33015 items; 264120 bytes total >> 8 bytes/item >> proto id: 7015 items; 84180 bytes total >> 12 bytes/item >> string data: 62775 items; 1537311 bytes total >> 2..1599 bytes/item; average 24 >> string id: 62775 items; 251100 bytes total >> 4 bytes/item >> type id: 5637 items; 22548 bytes total >> 4 bytes/item >> type list: 4202 items; 38558 bytes total >> 6..68 bytes/item; average 9 >> >> Everything works well on v.0.14.0. Any suggestions for what could go >> wrong? >> >> -- >> You received this message because you are subscribed to the Google Groups >> "adt-dev" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected] <javascript:>. >> For more options, visit https://groups.google.com/d/optout. >> > > > > -- > Xavier Ducrohet > Android SDK Tech Lead > Google Inc. > http://developer.android.com | http://tools.android.com > > Please do not send me questions directly. Thanks! > -- You received this message because you are subscribed to the Google Groups "adt-dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
