【发布时间】:2017-04-06 09:40:28
【问题描述】:
我的资产文件夹中有一个 db 文件(300mb)。当我运行代码时,它给了我以下错误
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.vmoptions 和 gradle.properties 中更改值,但它给了我同样的错误。
请帮忙
【问题讨论】:
-
为什么你有 300MB 的资产而不是使用扩展文件? developer.android.com/google/play/expansion-files.html
-
其实我要处理这个文件一两天,之后大小会减少到50MB,所以我没有去扩展文件。你有什么建议?
-
使用扩展文件。这个数据很可能不会改变,所以没有必要让主 APK 膨胀
-
我理解你的意思 Marcin 但问题是我不必使用这个 db 文件发布 apk。用户登录到应用程序后,将从服务器下载 db 文件。所以现在写数据库查询我把它放在资产文件夹中。有没有办法解决上述错误??
-
堆大于 1MB 怎么样?像2个左右?你试过吗?