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.