Android Studio Build Gradle OutOfMemoryError [英] Android Studio Build gradle OutOfMemoryError

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

问题描述

我是Android新手.我在Android Studio中导入了Github项目,但看到了这个问题`Error:java.lang.OutOfMemoryError:Java堆空间

I'm new in Android. I import Github project in Android studio, but i see this problem `Error:java.lang.OutOfMemoryError: Java heap space

错误:java.lang.OutOfMemoryError:Java堆空间 . 请在项目的gradle.properties文件中为Gradle分配更多内存. 例如,在gradle.properties文件中,以下行将最大Java堆大小设置为1,024 MB: org.gradle.jvmargs = -Xmx1024m 阅读Gradle的配置指南

Error:java.lang.OutOfMemoryError: Java heap space . 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: org.gradle.jvmargs=-Xmx1024m Read Gradle's configuration guide
Read about Java's heap size

我无法通过解决此问题. 我该怎么做才能解决这个问题?

I can't fix this problem with this . how should i do to fix that?

推荐答案

以下其中一种方法应为您工作:

One of the methods below should work for you:

方法1:

从项目树中打开gradle.properties文件 将此行添加到内存分配行

Open gradle.properties file from your project tree add this line at the memory allocation line

org.gradle.jvmargs=-XX\:MaxHeapSize\=256m -Xmx256m

org.gradle.jvmargs=-XX\:MaxHeapSize\=512m -Xmx512m

org.gradle.jvmargs=-XX\:MaxHeapSize\=1024m -Xmx1024m

取决于计算机的内存.然后

Depending on the Memory of your computer. Then

通过文件">使缓存/重新启动无效"使缓存/重新启动项目

Invalidate Caches/Restart project from the File > Invalidate Caches/Restart

要清理gradle缓存并实现新的堆大小内存更改

To clean up your gradle cache and implement your new heap size memory changes

方法2:

第1步:启动Android Studio并关闭所有打开的项目(文件">关闭项目").

Step 1 : Start Android studio and close any open project (File > Close Project).

第2步:在欢迎"窗口中,转到配置>设置.

Step 2 : On Welcome window, Go to Configure > Settings.

第3步:转到构建,执行,部署>编译器

Step 3 : Go to Build, Execution, Deployment > Compiler

第4步:将构建过程堆大小(兆字节)更改为512 ,并将虚拟机选项"的附加构建过程"更改为 -Xmx512m . 或与您的PC对应的任何内存分配

Step 4 : Change Build process heap size (Mbytes) to 512 and Additional build process to VM Options to -Xmx512m. Or any memory allocation in correspondent to your PC

第5步:重新验证/重新启动Android Studio.

Step 5 : Revalidate/Restart Android Studio.

方法3:

转到安装了Android Studio文件夹的位置.有文件 stduio.exe studio64.exe ,文件类型为 VMOPTIONS ,在记事本中打开该文件,您将看到类似以下内容:

Go to your Android Studio Folder Where it is installed. There is File stduio.exe and studio64.exe with file type of VMOPTIONS, open it in notepad you will see Something like this:

-Xms512m
-Xmx1280m
-XX:MaxPermSize=350m
-XX:ReservedCodeCacheSize=225m
-XX:+UseConcMarkSweepGC
-XX:SoftRefLRUPolicyMSPerMB=50
-ea
-Djna.nosys=true
-Djna.boot.library.path=

-Djna.debug_load=true
-Djna.debug_load.jna=true
-Dsun.io.useCanonCaches=false
-Djava.net.preferIPv4Stack=true
-Didea.paths.selector=AndroidStudio1.3
-Didea.platform.prefix=AndroidStudio

然后更改两个值以适合您的内存,如下所示

Then change two values to suite you memory as below

-Xms512m
-Xmx1280m

这篇关于Android Studio Build Gradle OutOfMemoryError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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