问题描述:
Error:Error converting bytecode to dex:
Cause: java.lang.RuntimeException: Unexpected exception in dex writer thread
Cause: java.lang.RuntimeException: Unexpected exception in dex writer thread
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: Error while executing java process with main class com.android.dx.command.Main with arguments {--dex --num-threads=4 --multi-dex --main-dex-list D:\workspace\android\mjhome\app\build\intermediates\multi-dex\debug\maindexlist.txt --output D:\workspace\android\mjhome\app\build\intermediates\transforms\dex\debug\folders\1000\1f\main D:\workspace\android\mjhome\app\build\intermediates\transforms\jarMerging\debug\jars\1\1f\combined.jar}
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: Error while executing java process with main class com.android.dx.command.Main with arguments {--dex --num-threads=4 --multi-dex --main-dex-list D:\workspace\android\mjhome\app\build\intermediates\multi-dex\debug\maindexlist.txt --output D:\workspace\android\mjhome\app\build\intermediates\transforms\dex\debug\folders\1000\1f\main D:\workspace\android\mjhome\app\build\intermediates\transforms\jarMerging\debug\jars\1\1f\combined.jar}
问题原因:
To run dex in process, the Gradle daemon needs a larger heap.
It currently has 512 MB.
For faster builds, increase the maximum heap size for the Gradle daemon to at least 1536 MB.
To do this set org.gradle.jvmargs=-Xmx1536M in the project gradle.properties.
It currently has 512 MB.
For faster builds, increase the maximum heap size for the Gradle daemon to at least 1536 MB.
To do this set org.gradle.jvmargs=-Xmx1536M in the project gradle.properties.
解决方法:
更改 gradle.properties 配置文件,把 org.gradle.jvmargs=-Xmx512m 改成 org.gradle.jvmargs=-Xmx1536m 就可以了。