Android 为什么Gradle会给出这个错误?
我正在构建一个应用程序,使用位置融合提供商和Firebase云消息传递。当我只使用Firebase云消息时,一切正常,但当我添加融合位置并想要构建应用程序时,console给了我以下错误:Android 为什么Gradle会给出这个错误?,android,android-gradle-plugin,fusedlocationproviderapi,Android,Android Gradle Plugin,Fusedlocationproviderapi,我正在构建一个应用程序,使用位置融合提供商和Firebase云消息传递。当我只使用Firebase云消息时,一切正常,但当我添加融合位置并想要构建应用程序时,console给了我以下错误: Error:Uncaught translation error: java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: GC overhead limit exceeded Error:1 error; ab
Error:Uncaught translation error: java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: GC overhead limit exceeded
Error:1 error; aborting
:presentation:transformClassesWithDexForDebug FAILED
Error:Execution failed for task ':presentation:transformClassesWithDexForDebug'.
com.android.build.api.transform.TransformException: `com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/lib/jvm/java-8-oracle/bin/java'' finished with non-zero exit value 1`
这是我的格拉德尔:
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
compileOptions.incremental = false
defaultConfig {
applicationId "com.telnet.asp"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
dataBinding {
enabled = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
apt 'com.google.dagger:dagger-compiler:2.2'
provided 'javax.annotation:jsr250-api:1.0'
compile project(path: ':domain')
compile project(path: ':data')
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.fasterxml.jackson.core:jackson-databind:2.7.0-rc2'
compile 'com.android.support:design:23.4.0'
compile 'javax.inject:javax.inject:1'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
compile 'io.reactivex:rxandroid:1.2.1'
compile 'io.reactivex:rxjava:1.1.6'
compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0'
compile 'com.google.dagger:dagger:2.2'
compile 'com.android.support:support-v4:23.4.0'
compile 'com.jakewharton:butterknife:6.1.0'
compile 'net.danlew:android.joda:2.9.4.1'
compile 'com.android.support:percent:23.4.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.google.firebase:firebase-messaging:9.0.0'
compile 'com.google.android.gms:play-services:9.0.0'
}
apply plugin: 'com.google.gms.google-services'
有人知道如何解决这个问题吗?请帮助。尝试添加
dexOptions {
javaMaxHeapSize "4g"
}
尝试添加
dexOptions {
javaMaxHeapSize "4g"
}
您需要将
dexOptions
添加到您的build.gradle
:
android {
compileSdkVersion 24
buildToolsVersion "23.0.3"
// ...
dexOptions {
incremental = true;
preDexLibraries = false
javaMaxHeapSize "4g" // 2g should be also OK
}
}
您需要将
dexOptions
添加到您的build.gradle
:
android {
compileSdkVersion 24
buildToolsVersion "23.0.3"
// ...
dexOptions {
incremental = true;
preDexLibraries = false
javaMaxHeapSize "4g" // 2g should be also OK
}
}
您的应用程序正试图分配更大的内存量,并且由于无法分配内存而导致内存不足 确保增加javaMaxHeapSize的
android {
//...
dexOptions {
incremental = true;
javaMaxHeapSize "4g" // tweak the value here if you need/want
}
// ...
}
此外,通过检查它们的堆栈跟踪,您的应用程序正在尝试分配更大的内存量,并且由于无法分配内存而将内存耗尽 确保增加javaMaxHeapSize的
android {
//...
dexOptions {
incremental = true;
javaMaxHeapSize "4g" // tweak the value here if you need/want
}
// ...
}
此外,通过检查它们的堆栈跟踪调用
buildToolsVersion“24.0.0”
并添加dexOptions{incremental true javaMaxHeapSize“4g”
调用buildToolsVersion“24.0.0”
并添加dexOptions{incremental true javaMaxHeapSize“4g”}
当我把这个条件放在gradle中时,是意味着我的问题在这个应用程序中永远解决了,还是只是暂时的,我应该做些事情来减少内存?让我们来看看整个问题。在本线程的上下文中,您讨论的是gradle内存,它指的是编译时内存。在这种情况下,您只需要增加编译堆,很可能会解决编译问题。如果您指的是应用程序内存(堆),则是。您应该始终处理内存使用情况,以防止内存泄漏或内存不足错误。检查这篇文章,当我把这个条件放在gradle中时,这是意味着我的问题在这个应用程序中永远解决了,还是只是暂时的,我应该做些事情来减少内存?让我们整体来看这个问题。在本线程的上下文中,您讨论的是gradle内存,它指的是编译时内存。在这种情况下,您只需要增加编译堆,很可能会解决编译问题。如果您指的是应用程序内存(堆),则是。您应该始终处理内存使用情况,以防止内存泄漏或内存不足错误。查看此帖子