java 无法在 Android Studio 2.1.1 的 gradle.properties 文件中设置 JVM 参数 gradle
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/37531536/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
JVM arguments gradle cannot be set in gradle.properties file for Android Studio 2.1.1
提问by Jim Clermonts
-Running Android 2.1.1 on Mac OS X
- 在 Mac OS X 上运行 Android 2.1.1
-App is not on Android phone.
- 应用程序不在 Android 手机上。
content of gradle.properties file
gradle.properties 文件的内容
org.gradle.jvmargs=-Xmx2048M
When hovering, the IDE indicates it is an unused property. It should also be dark blue instead of grey.
悬停时,IDE 指示它是一个未使用的属性。它也应该是深蓝色而不是灰色。
Output:
输出:
:MyProjectDirName:transformClassesWithInstantRunSlicerForDebug
:MyProjectDirName:transformClassesWithDexForDebug
To run dex in process, the Gradle daemon needs a larger heap.
It currently has approximately 910 MB.
For faster builds, increase the maximum heap size for the Gradle daemon
to more than 2048 MB.
To do this set org.gradle.jvmargs=-Xmx2048M in the project
gradle.properties.
For more information see
https://docs.gradle.org/current/userguide/build_environment.html
The output of the compiler clearly indicates it discards the contents of the gradle.propertiesfile.
编译器的输出清楚地表明它丢弃了gradle.properties文件的内容。
contents build.gradle
内容 build.gradle
android {
dexOptions {
javaMaxHeapSize "2g"
}
}
Played with these settings aswell, no success:
也玩过这些设置,没有成功:
回答by Rubin Yoo
Try to add the 'org.gradle.daemon=true' inside gradle.properties file at
尝试在 gradle.properties 文件中添加“org.gradle.daemon=true”
/Users/<username>/.gradle/ (Mac)
C:\Users\<username>\.gradle (Windows)
Answer based from
答案来自
https://stackoverflow.com/a/33184794/1915831
https://stackoverflow.com/a/33184794/1915831
回答by StarWind0
I faced this issue as well. Did not find a good answer. It is "nice" that you can fix it in your local properties folder. But people who suggest that must work on teams on 1, or want to spend time doing this fix to everyone. My group has a build server and that is the choke point.
我也遇到过这个问题。没有找到好的答案。您可以在本地属性文件夹中修复它,这“很好”。但是那些建议必须在 1 上的团队中工作的人,或者想要花时间对每个人进行此修复的人。我的小组有一个构建服务器,这就是瓶颈。
I confirmed that Gradle is actually reading these items and that the "not used" you are reading is an error. I confirmed this by changing one of the poperties like so
我确认 Gradle 实际上正在阅读这些项目,并且您正在阅读的“未使用”是一个错误。我通过像这样改变其中之一来确认这一点
org.gradle.jvmargs=-Xmx48m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
At which point I got an error. If it was not using this resource then it would not have errored with the following
在这一点上我得到了一个错误。如果它没有使用这个资源,那么它就不会出现以下错误
Error:Execution failed for task ':app:mergeDebugResources'.
GC overhead limit exceeded
回答by Merve Sahin
This works for me :
这对我有用:
properties file :
属性文件:
org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
build file :
构建文件:
android {
...
defaultConfig {
...
multiDexEnabled true
}
dexOptions {
preDexLibraries = false;
}
}