Android Studio 打包错误:Execution failed for task ':app:packageRelease'. java.lang.OutOfMemoryError
问题描述
在 Android Studio 中打包签名 Apk,分别点击 Build -> Generate Signed Bundle / APK...。但是编译的时候报错了,如下。
Execution failed for task ':app:packageRelease'.
> A failure occurred while executing com.android.build.gradle.tasks.PackageAndroidArtifact$IncrementalSplitterRunnable
> java.lang.OutOfMemoryError (no error message)
解决方法
修改安卓项目的 gradle.properties
文件,添加/修改 jvm 参数的堆大小:
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx4g
可以修改2g,如果还是出现内存溢出,再试试4g,慢慢增大。