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.
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.
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.
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
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.