android - 如何增加 Gradle 守护程序的最大堆大小?

标签 android gradle android-gradle-plugin

签署 apk 时,我收到以下消息:

To run dex in process, the Gradle daemon needs a larger heap.
It currently has 1024 MB.
For faster builds, increase the maximum heap size for the Gradle daemon to at least 4608 MB (based on the dexOptions.javaMaxHeapSize = 4g).
To do this set org.gradle.jvmargs=-Xmx4608M in the project gradle.properties.
For more information see https://docs.gradle.org/current/userguide/build_environment.html
在我的项目中,我没有 gradle.properties 文件,但我有一个名为 gradle-wrapper.properties 的文件。
我打开该文件并添加了 org.gradle.jvmargs=-Xmx4608M 行.
之后,我尝试再次签署 apk,但我仍然收到增加 Gradle 堆大小的消息。
如何做到这一点?

最佳答案

如果您没有 gradle.properties然后转到您的项目文件夹,您将在那里找到 gradle 文件创建一个文本文件并将其命名为 gradle.properties删除 .txt然后将以下代码添加到该文件中。

# Project-wide Gradle settings.

# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.

# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html

# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx4096m

# 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

并保存它,然后在 Android Studio 中打开您的项目,然后单击立即同步。

我希望它能解决您的问题,如果没有,请告诉我。

关于android - 如何增加 Gradle 守护程序的最大堆大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47454257/

相关文章:

Lollipop 之前的 android StateListAnimator

android - 返回在内部 fragment 中不起作用

android - 在 Gradle for Android 应用程序中运行 JUnit 测试

Android 依赖项 : apklib vs aar files

java - 如何在Android手机上制作RTSP服务器?

android - Android webview 中的所见即所得

android - 如何在Gradle中使用Gradle集成以及如何在Eclipse中创建build.gradle

javascript - Android Studio React Native 构建失败

android - 如何维护两个 google-services.json,production 和 debug

android - 9 补丁图像阻止构建项目 android studio