ERROR: cmd.exe failed with args Gradle

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.