android - 我该如何解决错误 : java. lang.OutOfMemoryError : GC overhead limit exceeded?

标签 android runtime-error

我更新了我的 Android Studio 并尝试运行一个应用程序,但它显示了这样的错误..

Error:Execution failed for task ':app:transformClassesWithDexForDebug'.> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: GC overhead limit exceeded

在更新Android Studio之前,相同的应用程序运行良好,所以我尝试解决这个问题,但我只发现了一个我已经在gradle文件中完成的问题。

dexOptions {
    incremental true
    javaMaxHeapSize "4g"
}

现在我该怎么办才能解决这个问题,请帮帮我。谢谢。

最佳答案

将其添加到您的 gradle.properties 文件中。

# The Gradle daemon aims to improve the startup and execution time of Gradle.
# When set to true the Gradle daemon is to run the build.
org.gradle.daemon=true

# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
org.gradle.parallel=true

# Enables new incubating mode that makes Gradle selective when configuring projects.
# Only relevant projects are configured which results in faster builds for large multi-projects.
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:configuration_on_demand
org.gradle.configureondemand=true

在我的 build.gradle 上:

....
     dexOptions
         {
               incremental false
               javaMaxHeapSize "2048M" 
               preDexLibraries = false
         }//end dexOptions

....

找到Here

我的回答Here

关于android - 我该如何解决错误 : java. lang.OutOfMemoryError : GC overhead limit exceeded?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36645795/

相关文章:

java - Android:带有 if else 语句的测验应用程序

android - 从 Windows 区域设置代码获取语言名称

ios - 将 UIGestureRecognizer 添加到 UITableViewCell

c# - 当前上下文中不存在该名称 - grrr

javascript - 发生Google Apps脚本服务器错误: DEADLINE_EXCEEDED

android - 需要 "How To"来为 Android 和 NDK 11 重建 OpenCV v2.4.12 和 v.3.1

android - Xamarin.Forms:单击后按钮文本对齐错误 (Android)

Android 电子市场应用内结算 IN_APP_NOTIFY 响应

python - "RuntimeError: generator raised StopIteration"每次我尝试运行应用程序时

r - Shiny :runExample 给出错误(不能从 `runApp()` 内调用 `runApp()` )