assign more memory to Gradle

时间:2021-09-09 03:49:50
Please assign more memory to Gradle in the project's gradle.properties file.For example, the following line, in the gradle.properties file, sets the maximum Java heap size to 1,024 MB:
<em>org.gradle.jvmargs=-Xmx1024m</em><a href="http://www.gradle.org/docs/current/userguide/build_environment.html">Read Gradle's configuration guide</a><br><a href="http://docs.oracle.com/javase/7/docs/technotes/guides/vm/gc-ergonomics.html">Read about Java's heap size</a>

studio编译出现上述错误

解决办法:C:\Users\username\.gradle中添加gradle.properties文件,文件中添加属性

org.gradle.jvmargs=-Xmx1024m

重启电脑即可。

上面添加的gradle.properties是全局的,也可在工程根目录下添加,仅对设置的工程有效。