我正在构建一个需要连接到python内置的Google应用引擎后端的应用。但是每次我构建应用程序时都会出现此错误。
Execution failed for task ':app:dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_11\bin\java.exe'' finished with non-zero exit value 1
我使用--stacktrace和--info运行构建并得到了这个
AGPBI: {"kind":"simple","text":"Uncaught translation error: java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: Java heap space","sources":[{}]}
AGPBI: {"kind":"simple","text":"Uncaught translation error: java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: Java heap space","sources":[{}]}
AGPBI: {"kind":"simple","text":"Uncaught translation error: java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: Java heap space","sources":[{}]}
AGPBI: {"kind":"simple","text":"Uncaught translation error: java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: Java heap space","sources":[{}]}
AGPBI: {"kind":"simple","text":"Uncaught translation error: java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: Java heap space","sources":[{}]}
AGPBI: {"kind":"simple","text":"5 errors; aborting","sources":[{}]}
build.gradle文件
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.test.testapp"
minSdkVersion 9
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
maven {
url 'http://google-api-client-libraries.appspot.com/mavenrepo'
}
mavenCentral()
mavenLocal()
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:design:23.1.0'
compile project(':app:libs:customerapi')
compile([group: 'com.google.api-client', name: 'google-api-client', version: '1.20.0'])
compile 'com.google.android.gms:play-services:8.1.0'
compile 'com.android.support:support-v4:23.1.0'
compile 'com.google.api-client:google-api-client-android:1.20.0'
compile 'com.android.support:multidex:1.0.1'
}
我不知道发生了什么,也无法找到解决方案。
答案 0 :(得分:3)
将它添加到build.gradle中的android闭包中:
dexOptions {
incremental true
javaMaxHeapSize "4g"
}
在https://groups.google.com/forum/#!topic/adt-dev/r4p-sBLl7DQ
上找到答案问题是java在gradle编译期间内存不足。增加堆大小将提高内存上限,允许编译成功完成。你需要将堆增加到4GB?不,但增加它解决了我遇到的问题 - 这恰好与原始海报相同。