SetupAndroid.bat Not Working for Any Engine Anymore!!!

Setting up Android. Doing all the necessary steps like I always do. But now SetupAndroid.bat has this ERROR

Android Studio Path: C:\Program Files\Android\Android Studio
Android Studio SDK Path: C:\Users[Username]\AppData\Local\Android\Sdk
Using sdkmanager: C:\Users[Username]\AppData\Local\Android\Sdk\cmdline-tools\latest\bin\sdkmanager.bat
Error: A JNI error has occurred, please check your installation and try again
Exception in thread “main” java.lang.UnsupportedClassVersionError: com/android/prefs/AndroidLocationsProvider has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:757)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
at java.lang.ClassLoader.loadClass(ClassLoader.java:419)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
at java.lang.ClassLoader.loadClass(ClassLoader.java:352)
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
at java.lang.Class.getMethod0(Class.java:3018)
at java.lang.Class.getMethod(Class.java:1784)
at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Update failed. Please check the Android Studio install.
Press any key to continue . . .

Is anyone else getting this? HELP!

20 Likes

I was getting the exact same error. I did this same install with UE 5.1 a few weeks ago and it worked fine. I compared the installs and it looks like there was an update to the Android command-line Tools.

Here’s how I fixed it:

  1. Go into Android Studio and under Configure → SDK Manager
  2. On the SDK Tools tab, select “Show Package Details” in the bottom right
  3. Uncheck Android SDK command-line Tools (latest)
  4. Check Android SDK command-line Tools 8.0
  5. Click Apply
  6. In Windows go to “C:\Users\USERNAME\AppData\Local\Android\Sdk\cmdline-tools” and rename the 8.0 folder to “latest”
  7. Run SetupAndroid.bat again

I think that was everything. Basically just need to downgrade the command line tools. You could also go into the SetupAndroid.bat file and change the path from “latest” to 8.0 if you want, either way should work.

52 Likes

Thank you! This seems to have worked!

1 Like

thanks alot, i wasted 3 hours with this error

1 Like

Thanks, I was trying to solve this error for exactly 1 day.

1 Like

You made my day!!!
on a mac the path to command-line-tools folder is: ~/Users/[you]/Library/Android/sdk/cmdline-tools/

1 Like

Oh man you are my life saver!!! Thanks!!

1 Like

Worked for me! Upvote this to the moon!!

1 Like

thank you man
it worked for me too

1 Like

Thank you. Been days trying to sort this one out. Appreciated!

1 Like

Thanks! it worked for me in UE5.2

1 Like

Man I wanna kiss you right now

1 Like

thank you baby

1 Like

yes, thanks for this! I was going to change engine :rofl:

1 Like

I can’t believe this solution is working. I have spent over 5 months to SOLVE THE PROBLEM WITH THIS .BAT FILE!!!

Hey, thanks this worked for me.

But while running the SetupAndroid.bat file, I got a warning: The expected path is different.

To avoid that, Instead of changing the folder name in step 6.
I followed the steps mentioned in the official UE documentation.

Which is to update the path of SDKMANAGERPATH in SetupAndroid.bat
From:```
set SDKMANAGER=%STUDIO_SDK_PATH%\cmdline-tools\latest\bin\sdkmanager.bat


TO: ```
set SDKMANAGER=%STUDIO_SDK_PATH%\cmdline-tools\8.0\bin\sdkmanager.bat

Directly modify the absolute path in SetupAndroid. bat

if DEFINED JAVA_HOME (set a=1) ELSE (
set JAVA_HOME=C:\Program Files\Java\jdk1.8.0_77\jre
setx JAVA_HOME “C:\Program Files\Java\jdk1.8.0_77\jre”