What is the purpose of SetupAndroid.bat?

Hello everyone! I’ve been having a hard time getting up and running with developing for Android (not working at all, tried on two computers, not even an unmodified template other than to set up Android will package), and in trying to set it up multiple times I’ve been wondering about the purpose of the “SetupAndroid.bat” script.

As I understand it, the purpose of this script seems to be to set up important file path variables for Unreal to know where the usable Android SDK, NDK and JRE are, as well as to download the compatible NDK. However, the NDK can be downloaded from Android Studio’s SDK manager, and all the paths can be set in the project settings. Does this mean this script can be entirely ignored if you make sure to manually set these paths and download the correct NDK?

I am just trying to get an understanding of how Unreal operates, but any discussion of any part of the process interests me.

(Bonus question: why is the script hard coded in terms of installation paths? I had to modify it because I have Unreal and Android Studio installed in a different drive than C:/, since they don’t fit there in one of my computers…)

  • From my experience which is not much, I`ve been able to build for Oculus Quest 2 which use Android SDK without problem. These are my steps.
  • -Install Android Studio , with all API Level SDK platform from 21 to 32.
  • -In SDK tools make sure Android SDK command line tools latest is installed.
  • -Before running your SetupAndroid.bat go to where android SDK is installed and Delete the folder “tools” if not the script will give you a Java error. ( this folder will be created again when you run the script)
  • -When building your project make sure you use arm64-v8a.
  • -if your environment variables are set correctly by the SetupAndroid.bat script you dont have to set up your SDK location in your Project Setting, but just in case do it, I dont think it will hurt.
    *- Very Important step, go to you android SDK build tools, usually in (C:\Users<yourusername>\AppData\Local\Android\Sdk\build-tools*) and rename D8.bat to Dx.bat in every folder if you have more than one. Also rename D8.jar to Dx.jar inside the lib folder.
    good luck
    Let me know :wink:

@TrueFranco thanks for the reply, but this didn’t work for me, I’m getting the same errors as before when trying to package (UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)): error: failed writing to ‘Z:\app\build\intermediates\runtime_symbol_list\debug\R.txt’: The data is invalid. (13).) In previous attempts I already had the “arm64-v8a” box ticked.

The “SetupAndroid.bat” did not re-download the “tools” folder and I had to modify the script again to help it find the “sdkmanager.bat” script which was in a different folder than its hardcoded expected path because of downloading the latest command line tools from the SDK manager in Android Studio (the one that says “(latest)”), which has slightly different paths in its folder.

Either way, my suspicion that the “SetupAndroid.bat” script can be avoided is still present (even if I can’t prove it because I can’t seem to build for Android anyway).