我一直在经历这个错误。在发布此问题之前,我已经搜索并尝试了其他解决方案。
这是我的build.gradle文件
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.apps.myApps"
minSdkVersion 14
targetSdkVersion 22
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
multiDexEnabled true
}
}
dexOptions {
preDexLibraries = false
}
}
afterEvaluate {
tasks.matching {
it.name.startsWith('dex')
}.each { dx ->
if (dx.additionalParameters == null) {
dx.additionalParameters = []
}
dx.additionalParameters += '--multi-dex'
}
}
dependencies {
provided fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:multidex:1.0.0'
compile "com.android.support:support-v4:18.0.+"
compile 'com.google.android.gms:play-services:7.5.0'
compile 'com.squareup:otto:1.3.8'
compile 'org.bouncycastle:bcprov-jdk15on:1.49'
compile 'net.simonvt.menudrawer:menudrawer:3.0.+@aar'
compile files('libs/acssmc-1.1.1.jar')
compile files('libs/activation.jar')
compile files('libs/additionnal.jar')
compile files('libs/android-async-http-1.4.6.jar')
compile files('libs/android-query-full.0.26.7.jar')
compile files('libs/androidmarketapi-0.6.jar')
compile files('libs/emvswipeapi-android-2.3.0.jar')
compile files('libs/mail.jar')
compile files('libs/newrelic.android.jar')
compile files('libs/nineoldandroids-2.4.0.jar')
compile files('libs/ormlite-android-4.47.jar')
compile files('libs/ormlite-core-4.47.jar')
}
我已经确定了
compile 'org.bouncycastle:bcprov-jdk15on:1.49'
导致非零退出值3。 在我评论之后,错误消失了。 但这个jdk很重要,我不能发表评论。
还有其他解决方法吗?
** 编辑 ** 添加了错误消息以帮助解决问题。
UNEXPECTED TOP-LEVEL ERROR:
java.lang.OutOfMemoryError: GC overhead limit exceeded
at com.android.dx.ssa.SetFactory.makeLivenessSet(SetFactory.java:91)
at com.android.dx.ssa.SsaBasicBlock.addLiveOut(SsaBasicBlock.java:792)
at com.android.dx.ssa.back.LivenessAnalyzer.liveOutAtBlock(LivenessAnalyzer.java:199)
at com.android.dx.ssa.back.LivenessAnalyzer.handleTailRecursion(LivenessAnalyzer.java:141)
at com.android.dx.ssa.back.LivenessAnalyzer.run(LivenessAnalyzer.java:188)
at com.android.dx.ssa.back.LivenessAnalyzer.constructInterferenceGraph(LivenessAnalyzer.java:93)
at com.android.dx.ssa.back.SsaToRop.<init>(SsaToRop.java:82)
at com.android.dx.ssa.back.SsaToRop.convertToRopMethod(SsaToRop.java:69)
at com.android.dx.ssa.Optimizer.optimize(Optimizer.java:101)
at com.android.dx.ssa.Optimizer.optimize(Optimizer.java:72)
at com.android.dx.dex.cf.CfTranslator.processMethods(CfTranslator.java:297)
at com.android.dx.dex.cf.CfTranslator.translate0(CfTranslator.java:137)
at com.android.dx.dex.cf.CfTranslator.translate(CfTranslator.java:93)
at com.android.dx.command.dexer.Main.processClass(Main.java:729)
at com.android.dx.command.dexer.Main.processFileBytes(Main.java:673)
at com.android.dx.command.dexer.Main.access$300(Main.java:83)
at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:602)
at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:632)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:505)
at com.android.dx.command.dexer.Main.runMultiDex(Main.java:334)
at com.android.dx.command.dexer.Main.run(Main.java:244)
at com.android.dx.command.dexer.Main.main(Main.java:215)
at com.android.dx.command.Main.main(Main.java:106)
Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/bin/java'' finished with non-zero exit value 3
答案 0 :(得分:3)
尝试像这样更新您的gradle文件(添加packagingOptions
):
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
...
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
}
我已经使用了整个build.gradle文件而没有任何错误。我的环境:
Android Studio 1.3.1
内部build.gradle(在项目文件夹中):
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
-MainActivity.java:
package com.example.testgradle;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.MenuItem;
public class MainActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
使用&#34; OutOfMemoryError更新:超出GC开销限制&#34;,尝试
dexOptions{
incremental true
javaMaxHeapSize "4g"
}