Error:Execution failed for task ':app:dexDebug'. > com.android.ide.common.process.ProcessException:

最近鼓捣android,遇到一个很奇葩的问题。

gradle编译不报错,但是打包运行时,提示:Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'D:\Program Files\Java\jdk1.8.0_31\bin\java.exe'' finished with non-zero exit value 2。整体如下图:

各种折腾,翻墙。总算搞定。感谢万能的度娘,感谢谷哥。

先说说引起这个问题的原因:

如果你是一个android开发者,你至少听说过的Dalvik的蛋疼的64K方法限制。概括地说,在一个DEX文件,你可以调用很多的方法,但你只能调用它们最前面的65,536个 ,因为这是在方法调用集合中的所有的空间了。如果你的源代码和狂拽炫酷叼炸天的三方库中方法超过了这个限制。

解决方案:

1.

添加依赖于你的build.gradle支持MultiDex库

dependencies { ... compile 'com.android.support:multidex:' ... }

2.

在buildType或productFlavor中开启multiDexEnabled。

defaultConfig { ... multiDexEnabled true ... }

3.

在manifest中,设置你的application,name

 <application

android :name="android.support.multidex.MultiDexApplication"

        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/Theme.AppCompat.Light.NoActionBar">

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值