干掉头疼的finished with non-zero exit value 2

很多次会出现 finished with non-zero exit value 2  .

Error:Execution failed for task ':app:dexDebug'. > com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdkx.x.x_xx\bin\java.exe'' finished with non-zero exit value 2


问群里小伙伴多数答案是:

1.clean   2.rebuild 3.重启 4.跳楼


可这几种方法往往不能解决问题。于是再一次遇到之后,求助stackoverflow 得到了以下说法:


There are two main reasons for this to happen

  1. You have same library or jar file included several places and some of them conflicting with each other.
  2. You are about or already exceed 65k method limit
大意是说,两种情况。

1.你的jar包或者库有重复。

2.你的方法超过65535。








第一种解决方案如下:

找出重复的依赖。

gradlew -q dependencies yourProjectName_usually_app:dependencies --configuration compile
多次排除之后 可能会得到

compile ('com.facebook.android:facebook-android-sdk:4.0.1'){
    exclude module: 'support-v4'
}

最后删除重复依赖的jar或者库即可。


说人话: 比如你的support v4重复依赖了。删除就好了。


第二种情况的解决方案:

1.尽量减少类的方法 和jar包类库。

2.如果第一条做不到则:

defaultConfig {
   ...
   ...
   multiDexEnabled true
}




  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值