Android Packaging in Unreal Engine 5.1

I’ve been trying everything to solve the problems that keep coming up when packaging a project for Android on Unreal Engine 5.1, but now I’m facing this problem with Gradle, here is the last Unreal log lines for the error.

UATHelper: Packaging (Android (ASTC)): FAILURE: Build failed with an exception.
UATHelper: Packaging (Android (ASTC)): * What went wrong:
UATHelper: Packaging (Android (ASTC)): Execution failed for task ':app:buildReleasePreBundle'.
UATHelper: Packaging (Android (ASTC)): > Required array size too large
UATHelper: Packaging (Android (ASTC)): * Try:
UATHelper: Packaging (Android (ASTC)): 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.
UATHelper: Packaging (Android (ASTC)): * Get more help at
UATHelper: Packaging (Android (ASTC)): BUILD FAILED in 1m 9s
UATHelper: Packaging (Android (ASTC)): ERROR: cmd.exe failed with args /c "C:\Users\VideoLab_01\Documents\Unreal Projects\VRTEST\Intermediate\Android\gradle\rungradle.bat" :app:bundleRelease
UATHelper: Packaging (Android (ASTC)):        (see C:\Users\VideoLab_01\AppData\Roaming\Unreal Engine\AutomationTool\Logs\C+Program+Files+Epic+Games+UE_5.1\Log.txt for full exception trace)
UATHelper: Packaging (Android (ASTC)): AutomationTool executed for 0h 5m 23s
UATHelper: Packaging (Android (ASTC)): AutomationTool exiting with ExitCode=1 (Error_Unknown)
UATHelper: Packaging (Android (ASTC)): BUILD FAILED
PackagingResults: Error: Unknown Error

“Required array size too large” I know only from OutOfMemoryError when you try to create a new array that is larger than remaining heap space. If you would run Gradle with --stacktrace, you would see the full error and where it happens. Then you could adjust the according heap setting to be large enough for your use-case.

I put the --stacktrace and it gave this log, Do you mean this error?:
UATHelper: Packaging (Android (ASTC)): > java.lang.OutOfMemoryError (no error message)
I’m going to look how to increase Java heap space and let you know if that solves it

1 Like

I put the --stacktrace and it gave this log, Do you mean this error?:

Wherever you gave --stacktrace, it was not to the Gradle build, because in your output you see it recommends to add --stacktrace, which it would not do if you have used it in the first place. :slight_smile:

But yeah, that is probable the one I meant.
The question is just where you need to increase the memory, there are various places in Gradle where you could do it, depending on where the error occurred, e.g. within the daemon or in a worker process. But I have no idea of Android or Unreal development, so I can just help generically.