How to Create a Working Android Gradle AAB Export Configuration for Google Play Store

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By dagrooms52

I’d like to use this as a the go-to question to figure out setting up Android Gradle AAB builds as I’ve sunk multiple hours into Android Studio & Gradle configuration.

When exporting a Godot (3.5) project for Android from a Windows machine, Gradle builds fail consistently if I have OpenJDK installed separately from the version that Android Studio installs. It is exceedingly difficult to bring the system back to golden configuration in this scenario; the easy way out has been to uninstall Android Studio, uninstall Java, clear out all folders that mention Java & Android from the C drive, then only reinstall Android Studio so that Gradle will consistently find the OpenJDK that is installed there. I am unable to please Gradle by setting the JAVA_HOME variable, even to the path that Android Studio has installed (though it refers to it as a JRE, despite claims of Android Studio bundling OpenJDK).

As I figure out more tips over the course of exporting for Android, specifically exporting AAB files (the only export compatible with the Google Play store), I will share them here.

Link dump for exporting AAB files for Google Play store:

Android’s instructions for the Godot AAB export:
Export Godot projects to Android  |  Android game development  |  Android Developers

The Android docs above have a broken link for “Generate an Upload Key and Keystore,” this is the new link:
Sign your app  |  Android Studio  |  Android Developers

dagrooms52 | 2023-01-09 16:13

Part of the issue is that Gradle preferred to use a Java 1.8 installation that I previously downloaded to build an APK from these instructions: Exporting for Android — Godot Engine (stable) documentation in English

Gradle did not honor the JAVA_HOME variable when it was set to a different JDK installation. I’ve uninstalled the OpenJDK 11 / Java 1.8 installation from above and removed it from the filesystem to force Gradle to look elsewhere.

dagrooms52 | 2023-01-12 15:22