如何在Android Studio 1.3中设置Gradle JVM设置 [英] How set Gradle JVM settings in Android Studio 1.3

查看:647
本文介绍了如何在Android Studio 1.3中设置Gradle JVM设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



我收到错误:

 错误:无法启动守护进程。 
这个问题可能是由于守护进程配置不正确引起的。
例如,使用无法识别的jvm选项。
请参阅http://gradle.org/docs/2.4/userguide/gradle_daemon.html
上的守护进程的用户指南一章。请阅读以下过程输出以了解更多信息:
-----------------------
VM初始化期间发生错误
无法为对象堆预留足够的空间
错误:无法创建Java虚拟机。
错误:发生致命异常。程序将会退出。

我的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 


Starting with version 1.3, Android Studio will no longer support IDE-specific Gradle JVM argument settings. Gradle JVM settings need to be set in gradle.properties files. This change is necessary to keep build output consistent, regardless of where the build is executed (IDE, command line or CI server.) If your project is using IDE-specific Gradle JVM arguments, Android Studio will, on project sync, help you copy those settings to your project's gradle.properties file. The "Gradle VM options" text field in the "Gradle" settings page has been removed as well.

I'm getting error:

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.  

My gradle.properties files

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

org.gradle.parallel=true

解决方案

Try changing your jvmargs to the following

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

Or something smaller -Xmx512m as your system does not have enough memory to create the object heap and thus the jvm.

You can also add the following option too:

 org.gradle.daemon=true

For those on macosx I like to add the following

-Djava.awt.headless=true

这篇关于如何在Android Studio 1.3中设置Gradle JVM设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆