关于Android Studio的gradle sync错误

来源:互联网 发布:中国软件排名 编辑:程序博客网 时间:2024/05/20 05:10

原错误:

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 https://docs.gradle.org/3.3/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 2097152KB object heap

Java HotSpot(TM) Client VM warning: ignoring option MaxPermSize=512m; support was removed in 8.0


用了各种手段:

先是删除C:\Users\Administrator\.gradle\wrapper\dists下的gradle文件夹,之后重新下载gradle,问题依旧。

其次File-> Setting ->Build,Execution, Deployment->Grade 取消offline work(希望其自己更新),然并卵。

再者File -> Invaildate Caches/Restart ,清除设置,问题仍旧

最后怒读.\gradle-3.3\docs\userguide\userguide.html的用户文档,发现没什么用

最终在stackoverflow中找到了答案,原贴如下:

http://stackoverflow.com/questions/22634644/java-hotspottm-64-bit-server-vm-warning-ignoring-option-maxpermsize


JDK 8的兼容性指南说,在Java 8中,命令行标志MaxPermSize已删除。原因是永久生成从热点堆中删除,并被移动到本机内存。所以为了删除这个消息编辑MAVEN_OPTS环境用户变量:

Java 7

MAVEN_OPTS -Xmx512m -XX:MaxPermSize=128m

Java 8

MAVEN_OPTS-Xmx512m

--------------------------

原来是Java 1.8选项不同,注意报错信息这句:warning: ignoring option MaxPermSize=512m; support was removed in 8.0

修改gradle.properties文件中的原来是Java 1.8选项不同,
原来是Java 1.8选项不同,修改

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

为这样:org.gradle.jvmargs=-Xmx512m -Dfile.encoding=UTF-8


再次同步,一切正常!

0 0