Android studio中的构建gradle错误 [英] Error in build gradle in Android studio

查看:583
本文介绍了Android studio中的构建gradle错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Android中的新手.i在Android工作室中导入github项目。但我看到这个问题`错误:java.lang.OutOfMemoryError:Java堆空间


错误:java.lang.OutOfMemoryError:Java堆空间

请在项目的gradle.properties文件中为Gradle分配更多内存。
例如,gradle.properties文件中的以下行将最大Java堆大小设置为1,024 MB:
org.gradle.jvmargs = -Xmx1024m


方法3:


转到Android Studio文件夹安装位置。文件类型为 VMOPTIONS 的文件 stduio.exe studio64.exe ,在记事本中打开它会看到类似这样的内容:

  -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

然后更改两个值以便为您​​的内存设置如下

  -Xms512m 
-Xmx1280m


im new in Android .i import github project in Android studio . but i see this problem `Error:java.lang.OutOfMemoryError: Java heap space

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

ican not fix this problem with this . how should i do to fix that?

解决方案

One of the methods below should work for you:

METHOD 1 :

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

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

or

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

or

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

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

METHOD 2 :

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

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

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

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

Step 5 : Revalidate/Restart Android Studio.

METHOD 3 :

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中的构建gradle错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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