记录一次开发中的报错信息
在安卓4.x以上运行程序都没有问题,就在4.x系统的手机上就报错:
Error:Execution failed for task ':yMKFGL: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 E:\oneworkspace\gitlab\yimao-kefu-android\YMKFGL\yMKFGL\build\intermediates\multi-dex\debug\maindexlist.txt --output E:\oneworkspace\gitlab\yimao-kefu-android\YMKFGL\yMKFGL\build\intermediates\transforms\dex\debug\folders\1000\1f\main E:\oneworkspace\gitlab\yimao-kefu-android\YMKFGL\yMKFGL\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 E:\oneworkspace\gitlab\yimao-kefu-android\YMKFGL\yMKFGL\build\intermediates\multi-dex\debug\maindexlist.txt --output E:\oneworkspace\gitlab\yimao-kefu-android\YMKFGL\yMKFGL\build\intermediates\transforms\dex\debug\folders\1000\1f\main E:\oneworkspace\gitlab\yimao-kefu-android\YMKFGL\yMKFGL\build\intermediates\transforms\jarMerging\debug\jars\1\1f\combined.jar}
解决办法:
在app的gradler配置文件中,添加 multiDexEnabled true 开启分包,然后添加:
dexOptions { javaMaxHeapSize "4g" } compileSdkVersion 26 buildToolsVersion '26.0.3' defaultConfig { multiDexEnabled true以上就能完美解决这个问题了。