签署 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/