Execution failed for task ‘:app:packageRelease’ at installRelease

I’m using React Native. When I want to lunch my app on Android (real device or emulator), it work perfectly.
But, when I want to creatte an aab file, I can’t lunch it.

Steps to reproduce :

  • cd android on the project.
  • ./gradlew clean and then ./gradlew bundleRelease to clean the project and create aab file.
  • app-release.aab is now in [your_project]/android/app/build/outputs/bundle/release
  • Then, ./gradle installRelease, or cd .. and react-native run-android --variant=release to lunch the aab on your device/emulator

When I do the last step, I got this error :

> Task :app:packageRelease FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:packageRelease'.
> A failure occurred while executing com.android.build.gradle.tasks.PackageAndroidArtifact$IncrementalSplitterRunnable
   > java.lang.OutOfMemoryError (no error message)

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

I looking for the solution but nothing work to solve Execution failed for task ':app:packageRelease' or A failure occurred while executing com.android.build.gradle.tasks.PackageAndroidArtifact$IncrementalSplitterRunnable

I also try to use Android Studio (Clean Project or Invalidate Caches/Restart) but doesn’t work.

Those someone has a solution ? Thanks

Environment Information

react-native-cli: 2.0.1
react-native: 0.63.0
gradle: 6.5

System:
    OS: macOS 10.15.7
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 182.55 MB / 16.00 GB
    Shell: 3.2.57 - /bin/bash
Binaries:
    Node: 12.18.3 - /usr/local/bin/node
    Yarn: Not Found
    npm: 6.14.6 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
Managers:
    CocoaPods: 1.9.3 - /usr/local/bin/pod
SDKs:
    iOS SDK:
        Platforms: iOS 14.3, DriverKit 20.2, macOS 11.1, tvOS 14.3, watchOS 7.2
    Android SDK:
        API Levels: 23, 25, 28, 29, 30
        Build Tools: 28.0.3, 29.0.3, 30.0.2
        System Images: android-29 | Google APIs Intel x86 Atom, android-29 | Google Play Intel x86 Atom, android-30 | Google Play Intel x86 Atom
      Android NDK: Not Found
IDEs:
    Android Studio: 4.1 AI-201.8743.12.41.6953283
    Xcode: 12.3/12C33 - /usr/bin/xcodebuild
Languages:
    Java: 1.8.0_242-release - /usr/bin/javac
    Python: 2.7.16 - /usr/bin/python
npmPackages:
    @react-native-community/cli: ^4.13.0 => 4.13.1 
    react: ^16.9.0 => 16.14.0 
    react-native: 0.63.0 => 0.63.0 
    react-native-macos: Not Found
npmGlobalPackages:
    *react-native*: Not Found

1 possible answer(s) on “Execution failed for task ‘:app:packageRelease’ at installRelease