How to fix Build Failed? Android Packaging

Hello!

I am new to developing and to using the Android package tool.
Trying to setup a VR project in UE 5.4 and build it for Android so I can use it in the Quest3.
I followed the instructions in this page

but probably missed something?
I am getting this in the log when trying to build for Android

Thanks in advance for any hints!

UATHelper: Packaging (Android (ASTC)): ====11/29/2024 11:13:53 AM====PERFORMING FINAL APK PACKAGE OPERATION=====arm64===========================================
UATHelper: Packaging (Android (ASTC)): Copied file E:\Documents\Unreal Projects\VR_Project\Intermediate\Android\arm64\gradle\app\src\main\jniLibs\arm64-v8a\libUnreal.so.
UATHelper: Packaging (Android (ASTC)): Directory Engine/Plugins/Runtime/AndroidFileServer/Source/AndroidFileServer/…/AFSStub copied to E:/Documents/Unreal Projects/VR_Project/Intermediate/Android/arm64/gradle/AFSProject (True)
UATHelper: Packaging (Android (ASTC)): Directory Engine/Plugins/Runtime/AndroidFileServer/Source/AndroidFileServer/Android copied to E:/Documents/Unreal Projects/VR_Project/Intermediate/Android/arm64/gradle/AFSProject/app/src/main (True)
UATHelper: Packaging (Android (ASTC)): Directory E:/Documents/Unreal Projects/VR_Project/Intermediate/Android/arm64/gradle/app/src/main/res copied to E:/Documents/Unreal Projects/VR_Project/Intermediate/Android/arm64/gradle/AFSProject/app/src/main/res (True)
UATHelper: Packaging (Android (ASTC)): Directory E:/Documents/Unreal Projects/VR_Project/Intermediate/Android/arm64/gradle/gradle copied to E:/Documents/Unreal Projects/VR_Project/Intermediate/Android/arm64/gradle/AFSProject/gradle (True)
UATHelper: Packaging (Android (ASTC)): Creating rungradle.bat to work around commandline length limit (using unused drive letter Z:)
UATHelper: Packaging (Android (ASTC)): Making .apk with Gradle…
UATHelper: Packaging (Android (ASTC)): To honour the JVM settings for this build a single-use Daemon process will be forked. See The Gradle Daemon.
UATHelper: Packaging (Android (ASTC)): Daemon will be stopped at the end of the build
UATHelper: Packaging (Android (ASTC)): FAILURE: Build failed with an exception.
UATHelper: Packaging (Android (ASTC)): * What went wrong:
UATHelper: Packaging (Android (ASTC)): Could not open settings generic class cache for settings file ‘Z:\settings.gradle’ (C:\Users\Usuario.gradle\caches\7.5\scripts\356clt8w0kvd14538qat92yfl).
UATHelper: Packaging (Android (ASTC)): > BUG! exception in phase ‘semantic analysis’ in source unit ‘BuildScript’ Unsupported class file major version 65
UATHelper: Packaging (Android (ASTC)): * Try:
UATHelper: Packaging (Android (ASTC)): > Run with --stacktrace option to get the stack trace.
UATHelper: Packaging (Android (ASTC)): > Run with --info or --debug option to get more log output.
UATHelper: Packaging (Android (ASTC)): > Run with --scan to get full insights.
UATHelper: Packaging (Android (ASTC)): * Get more help at https://help.gradle.org
UATHelper: Packaging (Android (ASTC)): BUILD FAILED in 2s
UATHelper: Packaging (Android (ASTC)): cmd.exe failed with args /c “E:\Documents\Unreal Projects\VR_Project\Intermediate\Android\arm64\gradle\rungradle.bat” :app:assembleDebug
UATHelper: Packaging (Android (ASTC)): (see C:\Users\Usuario\AppData\Roaming\Unreal Engine\AutomationTool\Logs\C+Program+Files+Epic+Games+UE_5.4\Log.txt for full exception trace)
UATHelper: Packaging (Android (ASTC)): AutomationTool executed for 0h 0m 53s
UATHelper: Packaging (Android (ASTC)): AutomationTool exiting with ExitCode=1 (Error_Unknown)
UATHelper: Packaging (Android (ASTC)): BUILD FAILED
PackagingResults: Error: Unknown Error

Error is here,

UATHelper: Packaging (Android (ASTC)): Could not open settings generic class cache for settings file ‘Z:\settings.gradle’ (C:\Users\Usuario.gradle\caches\7.5\scripts\356clt8w0kvd14538qat92yfl).

you’d better to open android-studio and create template project and try to build whether successful or not, it seems your android developing environment misses something…

Check out this video:
https://www.youtube.com/watch?v=FN4Vvdk3Q6A&t=45s

iv solved this problem before.

1.download gradle-6.1.1-all.zip
2.delete all files in this folder c:\user\currentusername.gradle\wrapper\dists\gradle-6.1.1-all\cfmwm155h49vnt3hynmlrsdst
3.copy zip file into this folder(Put the compressed file directly in it)
4.rebuild.

Thank you tootzoe, I will watch your video carefully and let you know how it goes

Thanks villinx! I tried this but didn’t work (tried both with gradle 6.1.1 and 7.5 which is the one I have)

In the post that you forwarded the answer marked as solved from pCooper focus on the Java version. I will have a look at that too.

u can refer to the version im currently using.

1 Like

Ah thanks all!

I just found a quick way to fix this. My fault!! I was looking at instructions for UE 5.0 and there is a new page with instructions for UE 5.4 which I missed, So I had to install Android Studio Flamingo | 2022.2.1 Patch 2 May 24, 2023 and follow the rest of the instructions.

here is the correct tutorial:

https://dev.epicgames.com/documentation/en-us/unreal-engine/set-up-android-sdk-ndk-and-android-studio-using-turnkey-for-unreal-engine?application_version=5.4

Thanks again

Found another fix

My issue was the gradle version was incompatible with the SDK version. Unreal just showed the gradle command output, which wasn’t helpful.

The fix

  1. Open the project in Android Studio. To open goto PROJECT_DIR/Intermediate/Android/gradle

  2. Try to build the project. It will fail, but it will tell you what is wrong. In my case it was the gradle version not being compatible with the Android SDK. There is also a popup offering to fix in in Android Studio

  3. Click the popup. Let Android Studio fix it for you.

  4. Restart your computer and package the build again