# Unreal 5.1 package project for Android error org.codehaus.groovy.vmplugin.v7.Java7 and java.lang.UnsupportedClassVersionError

**URL:** <https://forums.unrealengine.com/t/unreal-5-1-package-project-for-android-error-org-codehaus-groovy-vmplugin-v7-java7-and-java-lang-unsupportedclassversionerror/793309>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine, Android\
**Created:** [March 17, 2023, 11:48pm UTC](https://forums.unrealengine.com/t/unreal-5-1-package-project-for-android-error-org-codehaus-groovy-vmplugin-v7-java7-and-java-lang-unsupportedclassversionerror/793309 "2023-03-17T23:48:54Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Leomez](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Leomez](https://forums.unrealengine.com/u/Leomez)\
**Post date:** [March 17, 2023, 11:48pm UTC](https://forums.unrealengine.com/t/unreal-5-1-package-project-for-android-error-org-codehaus-groovy-vmplugin-v7-java7-and-java-lang-unsupportedclassversionerror/793309/1 "2023-03-17T23:48:54Z")

</div>

After 2 days of trying multiple things, I finally was able to make an APK for Android!! I just want to share this step-by-step in case of someone has the same problem. Also the documentation is here for reference: [https://docs.unrealengine.com/5.1/en-US/how-to-set-up-android-sdk-and-ndk-for-your-unreal-engine-development-environment/](https://docs.unrealengine.com/5.1/en-US/how-to-set-up-android-sdk-and-ndk-for-your-unreal-engine-development-environment/)

1 - Uninstall Android Studio and install Android Studio 4.0 from May 28, 2020 (yes it only works with this version, this was the biggest problem! )  
2 - Set the environment variables for ‘JAVA\_HOME’ to use the java version inside the android studio 4. ( inside the install folder from Android Studio there is a folder ‘jre’, with java version 1.8.0\_242 , that’s the only version that works! )  
3 - when installing the SKD, make sure to install the ‘Android SDK Command-line Tools’ version 8.0 (this is the only version that works. do not install other versions. On the documentation there is a print screen with step-by-step)  
4 - Download the NDK r25b version (this version is the ‘25.2.9519653’, do not download other versions!)  
5 - modify the ‘SetupAndroid.bat’ file that is inside ‘C:/Program Files/Epic Games/UE\_5.1/Engine/Extras/Android/SetupAndroid.bat’ . Change the line that says ‘cmdline-tools\latest’ to ‘cmdline-tools\8.0’ . (this file is inside the Unreal installation directory )  
6 - open the cmd and run ‘D:\ANDROID\_UNREAL\SDK\tools\bin\sdkmanager.bat --licenses’ ( replace ‘D:\ANDROID\_UNREAL’ with the directory you saved the SDK! Its normally ‘C:\Users\MyUserName\AppData\Local\Android’ )  
7 - Inside Unreal, on the options:  
- chose ‘Target SDK version’ to ‘30’ (won’t work with any version below 30)  
- chose ‘minimum SDK version’ to ‘26’  
- chose ‘SDK API Level’ to ‘30’  
- chose ‘NDK API Level’ to ‘latest’ (this one will only work with ‘latest’ if you **ONLY** download the correct version which is ‘25.2.9519653’)

### (change the location with the location on your computer)

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/2/e/12e1db919e51532d81c7f1c5d08ac6c77a506688.png)

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/6/5/c650cb74ac2484aa720835d82d0377467fa1b27a.png)

----- x -----  
While many attempts with the wrong configurations, I received the ‘BUILD FAILED’ many times. I will write here the error messages just to help people google this forum!

## When you try to package the project for Android:

UATHelper: Packaging (Android (ASTC)): Making .apk with Gradle…  
UATHelper: Packaging (Android (ASTC)): To honour the JVM settings for this build a new JVM will be forked. Please consider using the daemon: [The Gradle Daemon](https://docs.gradle.org/6.1.1/userguide/gradle_daemon.html).  
UATHelper: Packaging (Android (ASTC)): Daemon will be stopped at the end of the build stopping after processing  
UATHelper: Packaging (Android (ASTC)): java.lang.NoClassDefFoundError: Could not initialize class org.codehaus.groovy.vmplugin.v7.Java7  
PackagingResults: Error: Could not initialize class org.codehaus.groovy.vmplugin.v7.Java7  
UATHelper: Packaging (Android (ASTC)): Caused by: java.lang.ExceptionInInitializerError: Exception org.codehaus.groovy.GroovyBugError [in thread “Daemon worker”]  
PackagingResults: Error: Exception org.codehaus.groovy.GroovyBugError [in thread “Daemon worker”]  
UATHelper: Packaging (Android (ASTC)): … 128 more  
UATHelper: Packaging (Android (ASTC)): FAILURE: Build failed with an exception.  
UATHelper: Packaging (Android (ASTC)): \* What went wrong:  
UATHelper: Packaging (Android (ASTC)): Could not initialize class org.codehaus.groovy.reflection.ReflectionCache  
UATHelper: Packaging (Android (ASTC)): \> Exception java.lang.NoClassDefFoundError: Could not initialize class org.codehaus.groovy.vmplugin.v7.Java7 [in thread “Daemon worker”]  
UATHelper: Packaging (Android (ASTC)): \* Try:  
UATHelper: Packaging (Android (ASTC)): Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.  
UATHelper: Packaging (Android (ASTC)): \* Get more help at [https://help.gradle.org](https://help.gradle.org)  
UATHelper: Packaging (Android (ASTC)): BUILD FAILED in 5s  
PackagingResults: Error: Could not initialize class org.codehaus.groovy.vmplugin.v7.Java7 [in thread “Daemon worker”]  
UATHelper: Packaging (Android (ASTC)): ERROR: cmd.exe failed with args /c “C:\MyGame\Intermediate\Android\arm64\gradle\rungradle.bat” :app:assembleDebug  
UATHelper: Packaging (Android (ASTC)): (see C:\Users\MyUserName\AppData\Roaming\Unreal Engine\AutomationTool\Logs\E+UnrealEditor+UE\_5.1\Log.txt for full exception trace)  
PackagingResults: Error: cmd.exe failed with args /c “C:\MyGame\Intermediate\Android\arm64\gradle\rungradle.bat” :app:assembleDebug  
UATHelper: Packaging (Android (ASTC)): AutomationTool executed for 0h 0m 52s  
UATHelper: Packaging (Android (ASTC)): AutomationTool exiting with ExitCode=1 (Error\_Unknown)  
UATHelper: Packaging (Android (ASTC)): BUILD FAILED  
PackagingResults: Error: Unknown Error

## when you run ‘sdkmanager.bat --licenses’ with a Java version different than ‘1.8.0\_242’ :

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

---

<div class="post-metadata">

**Author:** ![Socke81](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/socke81/32/1194535_2.png) [@Socke81](https://forums.unrealengine.com/u/Socke81)\
**Post date:** [April 11, 2023, 3:28pm UTC](https://forums.unrealengine.com/t/unreal-5-1-package-project-for-android-error-org-codehaus-groovy-vmplugin-v7-java7-and-java-lang-unsupportedclassversionerror/793309/2 "2023-04-11T15:28:23Z")

</div>

Thank you. Unfortunately, you can not do everything this way. For example, there are no command tools in version 8 to choose from. There is only “latest” in the menu. With this it also works. What is important to fix this bug is the right Java version. If you already have another installed you have to enter the jre of Android Studio 4.0 in “Location of Java” (see screenshot above). For me it was: C:\Program Files\Android\Android Studio\jre

---

<div class="post-metadata">

**Author:** ![QuasiBear](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/quasibear/32/678838_2.png) [@QuasiBear](https://forums.unrealengine.com/u/QuasiBear)\
**Post date:** [April 28, 2023, 7:10am UTC](https://forums.unrealengine.com/t/unreal-5-1-package-project-for-android-error-org-codehaus-groovy-vmplugin-v7-java7-and-java-lang-unsupportedclassversionerror/793309/3 "2023-04-28T07:10:26Z")

</div>

My goodness THANK YOU! I have been trying to get past this for two weeks now. After uninstalling URE5 and all Android studio. Fresh start it worked. I didn’t have to change the sdkmanager.bat file at all? I don’t understand why it gives you all that in the Unreal Documentation? Anyways thanks again!

---

<div class="post-metadata">

**Author:** ![LukeKent1971](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@LukeKent1971](https://forums.unrealengine.com/u/LukeKent1971)\
**Post date:** [May 10, 2023, 7:04am UTC](https://forums.unrealengine.com/t/unreal-5-1-package-project-for-android-error-org-codehaus-groovy-vmplugin-v7-java7-and-java-lang-unsupportedclassversionerror/793309/5 "2023-05-10T07:04:11Z")

</div>

Thank you so much! 😂

---

<div class="post-metadata">

**Author:** ![ITSupportSpecBec](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ITSupportSpecBec](https://forums.unrealengine.com/u/ITSupportSpecBec)\
**Post date:** [May 15, 2023, 3:25am UTC](https://forums.unrealengine.com/t/unreal-5-1-package-project-for-android-error-org-codehaus-groovy-vmplugin-v7-java7-and-java-lang-unsupportedclassversionerror/793309/6 "2023-05-15T03:25:18Z")

</div>

Hello, thank you for this very helpful information. After successfully packaging and installing the apk in UE 5.1 in all 4 formats (ASTC, DXT, ETC2, & MULTI) and within all 4 binary configurations (DebugGame, Development, & Shipping) the app crashes a few seconds after it is loaded on my android device = Lenovo MH10 with Android 10 OS.

Would you happen to know if there are any other settings that should be checked in order to resolve this issue?

---

<div class="post-metadata">

**Author:** ![Agriarch](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/agriarch/32/1210170_2.png) [@Agriarch](https://forums.unrealengine.com/u/Agriarch)\
**Post date:** [June 1, 2023, 5:54pm UTC](https://forums.unrealengine.com/t/unreal-5-1-package-project-for-android-error-org-codehaus-groovy-vmplugin-v7-java7-and-java-lang-unsupportedclassversionerror/793309/7 "2023-06-01T17:54:26Z")

</div>

salute. After a week of head-scratching, your way solved my issue 👍

---

<div class="post-metadata">

**Author:** ![mapaa2](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@mapaa2](https://forums.unrealengine.com/u/mapaa2)\
**Post date:** [September 17, 2023, 8:55am UTC](https://forums.unrealengine.com/t/unreal-5-1-package-project-for-android-error-org-codehaus-groovy-vmplugin-v7-java7-and-java-lang-unsupportedclassversionerror/793309/8 "2023-09-17T08:55:55Z")

</div>

Thank you!

Had to download JDK 8.0.382 from azul and it finally worked.

---

<div class="post-metadata">

**Author:** ![Amalgamator](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Amalgamator](https://forums.unrealengine.com/u/Amalgamator)\
**Post date:** [December 31, 2023, 5:02pm UTC](https://forums.unrealengine.com/t/unreal-5-1-package-project-for-android-error-org-codehaus-groovy-vmplugin-v7-java7-and-java-lang-unsupportedclassversionerror/793309/9 "2023-12-31T17:02:05Z")

</div>

Hello, thank you so much for this post. Certinely has saved me a lot of time! Unfurtantly even though i followed the steps i still get an error saying

“ERROR: Android toolchain NDK r25c not supported; please use NDK r21 to NDK r23 (NDK r21b recommended)”

Now i can install the older NDK and get further, but then run in to another issue. Oh though there mus be something else at foot here in my set up as you are successfully compiling with r25B.

---

<div class="post-metadata">

**Author:** ![BustGame](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@BustGame](https://forums.unrealengine.com/u/BustGame)\
**Post date:** [January 14, 2024, 11:10pm UTC](https://forums.unrealengine.com/t/unreal-5-1-package-project-for-android-error-org-codehaus-groovy-vmplugin-v7-java7-and-java-lang-unsupportedclassversionerror/793309/10 "2024-01-14T23:10:20Z")

</div>

Guys, i have found solution which works for me:  
-Go to _ProjectName_\Intermediate\Android\arm64\gradle\gradle\wrapper  
-there you locate gradle-wrapper.properties  
-Open it in text file and at the bottom of the file there should be: “distributionUrl=https://services.gradle.org/distributions/gradle- **version** -all.zip”  
There you need to look at the version of gradle it uses.  
-go to [Gradle | Releases](https://gradle.org/releases/?_gl=1*1q4kzqc*_ga*MTcxNzk3NDU1LjE3MDUyNzE5Mzk.*_ga_7W7NC6YNPT*MTcwNTI3MTkzOS4xLjEuMTcwNTI3MzAwNi41Ny4wLjA).  
-locate your version of gradle and click on “User manual”  
-on the left side click on “Compatibility notes”  
-There you will find what java version it requires to run gradle  
-Download that version of java and install it inside AndroidStudio jre file  
-Package it/Deploy it on your android phone and play

My version of unreal is 5.1.1, gradle version is 6.1.1 and java version is 13.0.2

---

<div class="post-metadata">

**Author:** ![nande](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/nande/32/1057698_2.png) [@nande](https://forums.unrealengine.com/u/nande)\
**Post date:** [March 18, 2024, 5:07am UTC](https://forums.unrealengine.com/t/unreal-5-1-package-project-for-android-error-org-codehaus-groovy-vmplugin-v7-java7-and-java-lang-unsupportedclassversionerror/793309/11 "2024-03-18T05:07:37Z")

</div>

thanks. that was truly helpful.  
just in case, im using 5.2 and 5.3 and you can go down to sdk 29 (thank god, since htc vive has that as maximum).  
i use ndk : android-29 and sdk “matchndk”  
also ive been using ndk 25.1.89xxxx for a long time. i think that’ s the one listed in the android setup script so i left that one.  
i found the jdk from here are easy to install, just unzip. wonderful for testing. [Archived OpenJDK GA Releases](https://jdk.java.net/archive/)  
though the ideal is the sdk in the android/jre folder

i ran into this error when compiling in case someone else needs it

> <https://stackoverflow.com/questions/63640216/class-file-has-wrong-version-55-0-should-be-52-0-intellij>

htc had some java libraries compiled for v 55 and but java in the android folder is 52.  
i found with the previous post and this link that i could use version 11 [How to check Java version used to compile a class | dev cases](https://devcases.com/java/how-to-check-java-version-used-to-compile-a-class/)  
and that solved my issueS. (god i wish android were simpler).

---

<div class="post-metadata">

**Author:** ![2726559668](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@2726559668](https://forums.unrealengine.com/u/2726559668)\
**Post date:** [June 24, 2025, 3:00pm UTC](https://forums.unrealengine.com/t/unreal-5-1-package-project-for-android-error-org-codehaus-groovy-vmplugin-v7-java7-and-java-lang-unsupportedclassversionerror/793309/12 "2025-06-24T15:00:45Z")

</div>

A little bit misleading, though. SDK API Level should be something like `android-30` instead of `30`. Using numbers directly will default to latest API level.
