Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 779
M.Baraka Avatar asked Jan 06 '15 15:01

M.Baraka


People also ask

What is multidex application Android?

In Android, the compilers convert your source code into DEX files. This DEX file contains the compiled code used to run the app. But there is a limitation with the DEX file. The DEX file limits the total number of methods that can be referenced within a single DEX file to 64K i.e. 65,536 methods.

Is multidex needed?

Multidex support library is enabled by default in API level higher than 21 (Android 5 and higher). Therefore, you do not need to add the Multidex support library.

How do I enable Multidexenabled?

Android Multidex and the Dex Method Limit Enabling Multidex In order to enable a multidex configuration you need: to change your Gradle build configuration. to use a MultiDexApplication or enable the MultiDex in your Application class.


1 Answers

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.

like image 113
Scott Barta Avatar answered Sep 20 '22 15:09

Scott Barta