Android Studio模拟器错误 - 以非零退出值2结束

时间:2015-03-30 02:32:42

标签: android debugging gradle

所以我有一个应用程序我现在正在开发/测试一下,并且没有任何问题将它加载到我的手机上进行调试。有一天不知从哪里开始投掷和错误,并且不再让我运行模拟器了。错误如下:

* What went wrong:
Execution failed for task ':app:dexDebug'.
  

com.android.ide.common.process.ProcessException:org.gradle.process.internal.ExecException:进程'命令' C:\ Program Files \ Java \ jdk1.7.0_75 \ bin \的java.exe''完成非零退出值2

gradle控制台输出以下错误:

AGPBI: {"kind":"SIMPLE","text":"UNEXPECTED TOP-LEVEL EXCEPTION:","position":           {},"original":"UNEXPECTED TOP-LEVEL EXCEPTION:"}
AGPBI: {"kind":"SIMPLE","text":"com.android.dex.DexException: Multiple dex   files define Lbolts/AggregateException;","position":  {},"original":"com.android.dex.DexException: Multiple dex files define    Lbolts/AggregateException;"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)","position"     :{},"original":"\tat  com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)","position": {},"original":"\tat   com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)","position":{},"original":"\tat com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)","position":{},"original":"\tat com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.merge.DexMerger.merge(DexMerger.java:189)","position":{},"original":"\tat com.android.dx.merge.DexMerger.merge(DexMerger.java:189)"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)","position":{},"original":"\tat com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)","position":{},"original":"\tat com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.command.dexer.Main.run(Main.java:246)","position":{},"original":"\tat com.android.dx.command.dexer.Main.run(Main.java:246)"}
AGPBI: {"kind":"SIMPLE","text":"\tat  com.android.dx.command.dexer.Main.main(Main.java:215)","position": {},"original":"\tat com.android.dx.command.dexer.Main.main(Main.java:215)"}
AGPBI: {"kind":"SIMPLE","text":"\tat   com.android.dx.command.Main.main(Main.java:106)","position":{},"original":"\tat   com.android.dx.command.Main.main(Main.java:106)"}

我已经在SO和谷歌的几个案例中搜索了这个确切的错误,但这些解决方案似乎都没有。我也在下面附上了我的build.gralde文件。

apply plugin: 'com.android.application'

android {
compileSdkVersion 22
buildToolsVersion "22.0.0"

defaultConfig {
    applicationId "****"
    minSdkVersion 11
    targetSdkVersion 22
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.parse.bolts:bolts-android:1.+'
compile fileTree(dir: 'libs', include: 'Parse-*.jar')

任何人都可以在这里给我一些帮助吗?

2 个答案:

答案 0 :(得分:2)

在我的情况下,通过清理项目并从build.gradle中的依赖项中删除一些未使用的库来解决问题。

如果你必须保留库,那么你可以通过添加默认配置启用multi dex。

defaultConfig 
{        
    // Enabling multidex support.

    multiDexEnabled true
}

答案 1 :(得分:0)

  来自问题

的user3803709的

解决方案      

我必须在build.gradle

中注释掉以下内容
GcellCtrx testCell;

if (!_dictionary.TryGet(gcell.CellId, out testCell))
     _dictionary.Add(gcell.CellId, gcellGtrx);