2017-04-06 157 views
1

我在我的资产数据库文件(300MB)folder.When我运行它给了我下面的错误堆空间大小?

Error:Execution failed for task ':app:packageDebug'. 
> Java heap space 
ect'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> 

下面的代码是gradle.properties

# Project-wide Gradle settings. 

# IDE (e.g. Android Studio) users: 
# Gradle settings configured through the IDE *will override* 
# any settings specified in this file. 

# For more details on how to configure your build environment visit 
# http://www.gradle.org/docs/current/userguide/build_environment.html 

# Specifies the JVM arguments used for the daemon process. 
# The setting is particularly useful for tweaking memory settings. 


# When configured, Gradle will run in incubating parallel mode. 
# This option should only be used with decoupled projects. More details, visit 
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 
# org.gradle.parallel=true 


org.gradle.jvmargs=-Xmx1024m -XX:MaxPermSize=1024m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 

我试过很多东西像_JAVA_OPTIONS环境变量,更改值studio.exe.vmoptionsgradle.properties但它给了我同样的错误。

请帮忙

+0

为什么你有300MB的资产而不是使用扩展文件? https://developer.android.com/google/play/expansion-files.html –

+0

其实我必须在这个文件上工作一两天,之后的大小将减少到50MB,所以我没有去扩展文件。你有什么建议? –

+0

使用扩展文件。这个数据是最有可能不会改变,所以没有点腹胀主要APK –

回答

2

尝试增加java堆大小。以下是具体步骤:

查找内存指示Android Studio中的右下角

enter image description here

如果您没有看到这个选项,从Android Studio中首选项>外观和行为>外观启用>显示内存指示灯

enter image description here

增加Java堆大小:选择帮助>编辑自定义的虚拟机选项

enter image description here

更新studio.vmoptions文件中的Xmx值,当您选择上述选项时将打开该文件。对于8GB RAM我已经添加了这些价值,你可能需要调整基于您的系统配置:

-Xmx4096m 
-XX:MaxPermSize=1024m 

您还可以找到在〜/库/首选项文件/ AndroidStudio

重新启动的Android Studio和看如果你的记忆指标显示更新的值。