Skip to content Skip to sidebar Skip to footer

Generate Maindexlist Multidex For Maven

I am experiencing some build issues for an Android project. We had to start using multidex support given that we have over the 65K limit for methods. One thing I'm having issues wi

Solution 1:

I have the same warning with activeandroid

VFY: unable to resolve static method 

then fatal NoClassDefFound error finishes runtime process. It cannot be found some static methods sometimes it happens when device api is lower then target sdk api version. I found that mainDexClasses script can be helpful for joining all classes in one dex-file. Unfortunately this utility is not for my case. So I use dexdump utility for getting all classes which cannot be found by device

${ANDROID_HOME}/build-tools/[sdkNum]/dexdump target/classes.dex |grep "Class descriptor"|grep activeandroid >> MainDexList.txt

and add classes from classes2.dex to MainDexList.txt like above. Notice that there is getting only activeandroid package not entire class's list. Next, remove redundant prefix and suffix like this

sed -r "s/  Class descriptor  : 'L//g" MainDexList.txt>MainDexList.tmp;\
sed -r "s/;'/.class/g" MainDexList.tmp > MainDexList;\
rm MainDexList.tmp 

then specify MainDexList

<mainDexList>MainDexList</mainDexList>

in dex section of android-plugin configuration or use this file for dx utility.

I'm not clear undestand why 65k does limit method number. Have you enabled multiDex option (see here)? I guess it's a main reason why a few dex-files are generated and that's why there is a problem when one package is split to 2 files in my case. So we should avoid to get entire MainDexList as described above.

Post a Comment for "Generate Maindexlist Multidex For Maven"