Deploying to Android: Building an APK

I just fought my way through this problem and thought I’d share. These steps are heavily based on a previous guide from this forum. My main difficulty was that sdkmanager wants an older OpenJDK than Unity Hub already installs (currently 11).

  • Install the Android Build Support through Unity Hub.
  • Find the installation path of said Android Build Support. Mine landed at C:\Program Files\Unity\Hub\Editor\2022.3.22f1\Editor\Data\PlaybackEngines\AndroidPlayer. I will refer to that directory as just AndroidPlayer.
  • Install OpenJDK 8 from OpenLogic. Do not tell the installer to set environment variables. I used a zip download and moved the extracted folder (which contains bin and other directories) to AndroidPlayer\OpenJDK_8, right alongside the existing OpenJDK directory.
  • In a new command prompt, which you will also use for following commands:
cd AndroidPlayer\SDK\tools\bin
set JAVA_HOME = "wherever you put OpenJDK 8"
# Remember to expand "AndroidPlayer" to the full path.
  • To get a list of all available packages type sdkmanager.bat --list

  • You need to install:

  • SDK Build Tools

  • SDK Platform Tools

  • SDK Platform

Use one command or three (potentially easier to troubleshoot), but make sure to update version numbers:

sdkmanager.bat “build-tools;34.0.0” “platform-tools” “platforms;android-34”


- ```
sdkmanager.bat "build-tools;34.0.0"
sdkmanader.bat "platform-tools"
sdkmanager.bat "platforms;android-34"
1 Like

Do you have the error message when you build before you had to do this?