Android Studio 打包错误:Execution failed for task ':app:packageRelease'. java.lang.OutOfMemoryError

Android 2021-10-15 阅读 881 评论 0

问题描述

在 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,慢慢增大。

最后更新 2021-10-15
MIP.watch('startSearch', function (newVal, oldVal) { if(newVal) { var keyword = MIP.getData('keyword'); console.log(keyword); // 替换当前历史记录,新增 MIP.viewer.open('/s/' + keyword, {replace: true}); setTimeout(function () { MIP.setData({startSearch: false}) }, 1000); } }); MIP.watch('goHome', function (newVal, oldVal) { MIP.viewer.open('/', {replace: false}); });