I’m trying to package a very simple project to apk for android and I get the following error. I’ve searched a lot and still couldn’t find how to fix it. Please help!
UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)): Making .apk with Gradle…
UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)): Downloading https://services.gradle.org/distributions/gradle-6.1.1-all.zip
UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)): …
UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)): Unzipping C:\Users\Panagiotis.gradle\wrapper\dists\gradle-6.1.1-all\cfmwm155h49vnt3hynmlrsdst\gradle-6.1.1-all.zip to C:\Users\Panagiotis.gradle\wrapper\dists\gradle-6.1.1-all\cfmwm155h49vnt3hynmlrsdst
UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)): Welcome to Gradle 6.1.1!
UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)): Here are the highlights of this release:
UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)): - Reusable dependency cache
UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)): - Configurable compilation order between Groovy/Kotlin/Java/Scala
UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)): - New sample projects in Gradle’s documentation
UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)): For more details see Gradle 6.1.1 Release Notes
UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)): To honour the JVM settings for this build a new JVM will be forked. Please consider using the daemon: The Gradle Daemon.
UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)): FAILURE: Build failed with an exception.
UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)): * What went wrong:
UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)): Unable to start the daemon process.
UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)): This problem might be caused by incorrect configuration of the daemon.
UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)): For example, an unrecognized jvm option is used.
UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)): Please refer to the User Manual chapter on the daemon at The Gradle Daemon
UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)): Process command line: C:\Program Files (x86)\Eclipse Adoptium\jdk-8.0.352.8-hotspot\bin\java.exe -XX:MaxHeapSize=4096m -Xmx9216m -Dfile.encoding=windows-1252 -Duser.country=US -Duser.language=en -Duser.variant -cp C:\Users\Panagiotis.gradle\wrapper\dists\gradle-6.1.1-all\cfmwm155h49vnt3hynmlrsdst\gradle-6.1.1\lib\gradle-launcher-6.1.1.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 6.1.1
UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)): Please read the following process output to find out more:
UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)): -----------------------
UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)): Error: Could not create the Java Virtual Machine.
UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)): Error: A fatal exception has occurred. Program will exit.
UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)): Invalid maximum heap size: -XX:MaxHeapSize=4096m
UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)): The specified size exceeds the maximum representable size.
UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)): * Try:
UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)): 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 (Multi:ASTC,DXT,ETC2)): * Get more help at https://help.gradle.org
PackagingResults: Error: Could not create the Java Virtual Machine.
PackagingResults: Error: A fatal exception has occurred. Program will exit.
UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)): ERROR: cmd.exe failed with args /c “D:\Unreal Engine Vault\Projects\CotA\CotA\Intermediate\Android\arm64\gradle\rungradle.bat” :app:assembleDebug
UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)): (see C:\Users\Panagiotis\AppData\Roaming\Unreal Engine\AutomationTool\Logs\C+Unreal+Engine+UE_5.2\Log.txt for full exception trace)
PackagingResults: Error: cmd.exe failed with args /c “D:\Unreal Engine Vault\Projects\CotA\CotA\Intermediate\Android\arm64\gradle\rungradle.bat” :app:assembleDebug
UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)): AutomationTool executed for 0h 0m 51s
UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)): AutomationTool exiting with ExitCode=1 (Error_Unknown)
UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)): BUILD FAILED
PackagingResults: Error: Unknown Error
I've tried googling around but I didn't find any solution...
The main problem is that you have installed a 32bit Java Development Kit in the path
C:\Program Files (x86)\Eclipse Adoptium\jdk-8.0.352.8-hotspot
. And it seems this JDK is configured to be used by Gradle (usually by theJAVA_HOME
ENV variable). 32 bit software on Windows is usually limited to 2GB max RAM (in special cases 3Gb are possible). But Gradle wants to use 4GB max heap size which is not possible with a 32bit JRE/JDK (Invalid maximum heap size: -XX:MaxHeapSize=4096m
).My recommendation would be to uninstall all 32 bit versions of Java Runtime and Development Kit. Make sure you have a Java 8 64bit JDK version installed and configure your environment variable
JAVA_HOME
to point to the installation directory. Then the Gradle errorInvalid maximum heap size: -XX:MaxHeapSize=4096m
will disappear.