ERROR: cmd.exe failed with args Gradle

Hello, I am running into a weird error when I try to build out my game to Android (ASTC) for Oculus Quest.

UATHelper: Packaging (Android (ASTC)): ERROR: cmd.exe failed with args /c "S:\Unreal Projects\[GAME]\Intermediate\Android\APK\gradle\rungradle.bat" :app:assembleDebug UATHelper: Packaging (Android (ASTC)): Took 29.906301s to run UnrealBuildTool.exe, ExitCode=5 UATHelper: Packaging (Android (ASTC)): UnrealBuildTool failed. See log for more details. (C:\Users\kenda\AppData\Roaming\Unreal Engine\AutomationTool\Logs\S+Program+Files+Epic+Games+UE_4.24\UBT-[GAME]-Android-Shipping.txt) UATHelper: Packaging (Android (ASTC)): AutomationTool exiting with ExitCode=5 (5) UATHelper: Packaging (Android (ASTC)): BUILD FAILED PackagingResults: Error: cmd.exe failed with args /c "S:\Unreal Projects\[GAME]\Intermediate\Android\APK\gradle\rungradle.bat" :app:assembleDebug PackagingResults: Error: Unknown Error

Things to note:

  • I have already tried reinstalling Android Codeworks

  • I have already accepted the SDK license

  • I was able to successfully make a build using the same settings in a blank project

  • Android Studio is already installed

  • I’ve cleared the cache in my user folder

Right now, I am not sure what else to do. So help would be greatly appreciated!

Also, here are my apk settings.

1 Like

So far, no right answer for this. Trying to package with 4.23, 4.24, 4.25, no luck, even empty project. I’m so frustrated right now.

I had this same problem and took me a while to find something that worked for me.

I’m using 4.25 and have a clean install of Android Studio and Java.

From reading the bug reports on the gradle github - seems that the solution is to download JDK v. 8 - I did this, repointed my Unreal settings to here - and then it worked smoothly.

Hope this answer helps someone.

Unfortunately, there was no luck on my end. It must be something specific with my game, since I’m able to build in other projects.

I was just comparing settings - and seems the only difference is the minimum SDK version (I’m using 19).

Maybe that could be the issue…

Sadly, it’s still failing with the same error. The only other difference I see is that you’re not packaging your game inside an apk, which I am.

I spent a day fighting the same problem. I had been successfully building for android for months then I started getting gradle errors. I thought maybe it was due to project size or upgrading to Unreal 25.3. I reloaded Android Studio, reviewed every build setting, editing ini files, all with no success. Then I backed up my project and deleted the Saved directory. That fixed it.
Very frustrating problem to solve and in hindsight I wish I had started with deleting the Saved and Intermediate folders. So I thought I would share this in case it can help someone else.

2 Likes

Thanks for reaching out! I have tried deleting those directories before with no luck. Perhaps, I will try it again!

I had this problem for a week, trying on two laptops with zero success. Found this video , titled: UNREAL ENGINE 4.25.1 PACKAGING FOR ANDROID TUTORIAL UPDATED! : UNREAL ENGINE 4.25.1 PACKAGING FOR ANDROID TUTORIAL UPDATED! - YouTube

I removed all of the files for android studio and codeworks (which took some work for some reason) and started with this process from scratch, also installing JDK 15 fresh.

It worked. The “cmd.exe failed with args /c” failure is gone. I hope this works for you. I spent a week looking for the answer, and this 20 minute step-by-step setup solved the problem.

side note: my desktop system has not had this issue at all, and is still set up differently, for some reason the laptops would not work unless this exact setup is in place.

In my case was about minimun SDK version, I only can package on 26 or upper but idk why.

I had the same issue. Try this:

  1. Go to your project folder
  2. search for .apk
  3. delete all .apk files (not the files that only contain apk in their names), especially a file that contains “debug” and “.apk”
  4. Package project 5. Success

cheack out this

Thanks, i deleted Intermediate and it help

Deleting Saved and Intermediate worked for me. Thanks!
(UE4.26 on Win10. Laptop: Razer Blade 15 Base 2020)

This worked for me - deleted Saved and Intermediate folders and was able to package again! (When I ran it the first time I had issues with SDK locations etc. I believe following the YT Tut for packaging Android can work but instead of using open jdk I installed java via Chocolatey which handles a lot - you should still follow his steps in any case - Oracle can suck a D for making things so difficult now (or UE4 but my main bet is Oracle))

Some other hot tips:

REMEMBER TO RUN THE ANDROID BAT FILE IN UE4> ENGINE > Extras > Android

100%worked
(1) install Extras

344764-capture223.jpg

(2) delete the folder android-ndk-r18b
Location C:\NVPACK

(3) download android-ndk-r21e
link Descargas de NDK  |  NDK de Android  |  Android Developers

(4) copy android-ndk-r21e to C:\NVPACK
again

(5) package project again

Have fun

Had exactly the same issue. For me, installing proper version of Java fixed this issue, so now I have following:
UE4 4.27.1
Java JDK 1.8.0_202
Android SDK 28.0.0. and 29.0.2
Android NDK 21.0.6113669
Device: Galaxy S20
I can launch project on device and I can create package.

I got the same problem, but the JDK version of 1.8.0_202 fixed this issue. Thank you.