Search code examples
androidandroid-studioandroid-multidex

android multidex implementation


I am having this error .

Error:Execution failed for task ':myApp:createDebugMainDexClassList'. com.android.ide.common.internal.LoggedErrorException: Failed to run command: java -Xmx1024M -cp \android-sdk\build-tools\19.1.0\lib\dx.jar com.android.multidex.ClassReferenceListBuilder myApp\build\intermediates\multi-dex\debug\componentClasses.jar myApp\build\intermediates\multi-dex\debug\allclasses.jar

Error Code: 1 Output: Error: Could not find or load main class com.android.multidex.ClassReferenceListBuilder

I am trying to use the multidex library because my application went over the 65000 method because i am using external libraries as Link describes ,I have added the lines in mainfest and build.gradle file,any tips would be appreciated.Thanks

EDIT after few launches I got this error.

Error:Execution failed for task ':myApp:dexDebug'. com.android.ide.common.internal.LoggedErrorException: Failed to run command: \android-sdk\build-tools\21.1.0\dx.bat --dex --no-optimize --multi-dex --main-dex-list myApp\build\intermediates\multi-dex\debug\maindexlist.txt --output myApp\build\intermediates\dex\debug --input-list=myApp\build\intermediates\tmp\dex\debug\inputList.txt ,,Error Code:3.

Output: UNEXPECTED TOP-LEVEL ERROR: java.lang.OutOfMemoryError: Java heap space

I tried to increase the size of Xms1024m -Xmx1024m which is in file 'studio64.exe.vmoptions' but it still does not help ,I also tried in Settings>Compiler>VM Options Xms1024m -Xmx1024m


Solution

  • According to the multidex docs at https://developer.android.com/tools/building/multidex.html you need to be running build tools 21.1.0 or higher to use multidex. By your error message it looks like you're using 19.1.0. Try upgrading.