FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':***:dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_80\bin\java.exe'' finished with non-zero exit value 2
* Try:
* What went wrong:
Execution failed for task ':***:dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_80\bin\java.exe'' finished with non-zero exit value 2
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
网上的很多说是有重复的jar包,V4、V7等原因,我这个都没发现。
本人的解决方法:在主工程的build.gradle文件中增加如下代码解决,
multiDexEnabled true
作用:允许AndroidStudio对发布的项目进行分包处理,发不出的APK会有两个dex文件,
分析原因可能是项目代码过于庞大,方法超过65536,但不知道为什么AS没有报65536错误,主工程引用了好几个Lib库。
注:增加这个代码后,需要改变build tool版本到21以上,提示说是21版本编译才开始支持分包。