android - 如何在 Android Studio 1.3 中设置 Gradle JVM 设置

标签 android android-studio gradle

从 1.3 版本开始,Android Studio 将不再支持特定于 IDE 的 Gradle JVM 参数设置。 Gradle JVM 设置需要在 gradle.properties 文件中设置。无论在何处执行构建(IDE、命令行或 CI 服务器),此更改都是保持构建输出一致所必需的。 如果您的项目使用特定于 IDE 的 Gradle JVM 参数,Android Studio 将在项目同步时帮助您将这些设置复制到项目的 gradle.properties 文件中。 “Gradle”设置页面中的“Gradle VM 选项”文本字段也已被删除。

我收到错误:

Error:Unable to start the daemon process.
This problem might be caused by incorrect configuration of the daemon.
For example, an unrecognized jvm option is used.
Please refer to the user guide chapter on the daemon at     http://gradle.org/docs/2.4/userguide/gradle_daemon.html
Please read the following process output to find out more:
-----------------------
Error occurred during initialization of VM
Could not reserve enough space for object heap
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.  

我的 gradle.properties 文件

org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

org.gradle.parallel=true

最佳答案

尝试将您的 jvmargs 更改为以下内容

org.gradle.jvmargs=-Xmx1024m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

或者更小的-Xmx512m,因为您的系统没有足够的内存来创建对象堆和 jvm。

您还可以添加以下选项:

 org.gradle.daemon=true

对于那些在 macosx 上的人,我想添加以下内容

-Djava.awt.headless=true

关于android - 如何在 Android Studio 1.3 中设置 Gradle JVM 设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30764928/

相关文章:

Android - 使用 Joda Time 时无法使用 Proguard 导出 apk

android - 如何使 Hugo 和 AndroidDevMetrics 插件仅在调试 : 中编译

java - Android Studio 找不到符号变量

尽管我选择了网络摄像头作为来源,但 Android 虚拟设备摄像头无法正常工作

java - 如何获取 map 上点击位置的 GeoPosition?

gradle - 为什么包含特定的 jar 文件?

android - 使用IndoorAtlas库的transformClassesWithDexForDebug

android - 如何在 Android Studio 中添加测试文件夹

android - 错误:任务 ':app:transformClassesWithDexForRelease'的执行失败-Android Studio

android - 我无法在 Google Play 商店中更新 : Version error