SetupAndroid.bat UE4.25 Error

Hello,

I tried to install Android Studio for UE4.25. I upgraded my previous project from 4.24, where I used CodeWorks.

Now I uninstalled CodeWorks, installed Android Studio and got a few errors when running the SetupAndroid.bat file:

  1. No SDK found (or something similar) → fixed it by installing some stuff via “SDK Manager” in Android Studio (dont remember the exact component)
  2. ERROR: JAVA_HOME is set to an invalid directory: C:\NVPACK\jdk1.8.0_77 → fixed by installing OpenJDK 14 and setting the Environment Variable right
  3. Android Studio Path: “C:\Program Files\Android\Android Studio”
    Android Studio SDK Path: C:\NVPACK\android-sdk-windows
    Using sdkmanager: C:\NVPACK\android-sdk-windows\tools\bin\sdkmanager.bat
    Exception in thread “main” java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
    at com.android.repository.api.SchemaModule$SchemaModuleVersion.(SchemaModule.java:156)
    at com.android.repository.api.SchemaModule.(SchemaModule.java:75)
    at com.android.sdklib.repository.AndroidSdkHandler.(AndroidSdkHandler.java:81)
    at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:73)
    at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:48)
    Caused by: java.lang.ClassNotFoundException: javax.xml.bind.annotation.XmlSchema
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:602)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
    … 5 more
    Update failed. Please check the Android Studio install.
    Drücken Sie eine beliebige Taste . . .

And this is the Error I´m completely stuck and lost.
I would appreciate any help!

1 Like

I’m stuck in the same error . Someone got a solution?

Please help!

I managed to get around this problem by removing the JAVA_HOME from PATH.

2 Likes

I ran into this issue as well when going through the steps on the wiki, removing JAVA_HOME seems from my path seems to have resolved it for me as well - thank you!

2 Likes

I struggled with this fro 2 days then I found this very useful video,
It works like a charm
Let’s all give him a thumbs up guys

2 Likes

To anyone who may be following this to find a solution on why the HAXM error persists despite the virtualization is enabled, and the Hyper-V is off. Here is one apparently common thing which may be causing this in Win10: get to Edit Group Policy, Administrative Templates, System, Device guard and there will be two subcategory options. Normally they are set to Default, but you need to set them to Disabled.

Make sure you know what you are doing though, and happy developing! cheers

Thank you so much, this worked!

Thank you so much miracle7. You just made my day brother. I was suffering and being frustrated with this problem for last 3 days.

May Allah bless you.

NP ma dude, have a nice day!

Removing JAVA_HOME from PATH sorted it for me also

If I can ask a stupid question,
How / where do you remove JAVA HOME and secondly is there a safe way of backing it up incase it screws over other things on my system?

1 Like

search path in windows search open edit system environment variable → Enviroment Variables… ->select JAVA_HOME and delete it.

If you want to undo this delete you should save the current path to JAVA_HOME somewhere and you can easily add it back with the new button.

2 Likes

Ive been stuck on this for 3 hours, this fixed it! Thank you so much

Another solution which might be better: If you have previously installed java on your machine, instead of removing the env variable JAVA_HOME, you should simply change it’s path to the one that you had installed.

In my case, it was: “C:\Program Files\Java\jre1.8.0_51”, so I pointed the JAVA_HOME to this path. This shall prevent breaking other softwares which might also be using the JAVA_HOME variable to locate the java installation directory to use java.

Beware: if your java version mismatches the android studio java version by a significant margin, then you might face other problems too, maybe simply install the same version of java on your machine as that of the one which android studio has installed and point the env variable to that version instead.

1 Like

You posted this only a few hours before I had the same issue. Your solution worked! I had two JRE folders, one in C:\Program Files\Android\Android Studio\jre and the other at C:\Program Files\Java\jre1.8.0_301.

Making JAVA_HOME C:\Program Files\Java\jre1.8.0_301 in environment variables settings fixes it and allows me to run androidsetup.bat without error!

I am in the process of compiling my android game and this should help me fully compile the games and put them out on the google play store etc. Thanks!

edit: I actually had to set the path to this: C:\Program Files\Java\jdk1.8.0_211 after installing jdk8 using chocolatey. this worked. jre doesn’t have tools.jar.

1 Like

Glad that it helped, I don’t usually post =))

Two more things in case more people get stuck:

1 - If you have recently installed or updated Android Studio, it installs java version 11, but unreal 4 relies heavily on java 8 as of now, so it is better simply point the variable to that. But keep in mind that if you ever use android studio, you might again need java 11 for some specific library to compile/work, so you might have to change that back OR change android studio settings to make it use java version at a manually defined path (point to java 11).

2 - If your game does not package, remove sdk build tools version 31.0.0 and install 30.0.3 or lower. See my answer here for more details.

It seems the problem is caused by the built-in command-line tools not supporting newer Java versions.

What allowed me to complete the script successfully was this: Getting Android sdkmanager to run with Java 11 - Stack Overflow.

  1. Install Android Studio.
  2. Open Android Studio and install Command-Line Tools.

  1. Update \Engine\Extras\Android\SetupAndroid.bat:

    set SDKMANAGER=%STUDIO_SDK_PATH%\cmdline-tools\latest\bin\sdkmanager.bat
    IF EXIST “%SDKMANAGER%” (
    echo Using sdkmanager: %SDKMANAGER%
    ) ELSE (
    set SDKMANAGER=%STUDIO_SDK_PATH%\cmdline-tools\latest\bin\sdkmanager.bat

4 Likes

the hero we deserve

He knows! He knows!