How to fix Android Gradle Build failed error in unity
There is a simple way to resolve this error if you are using older version than unity 2019
Just go to build setting setting and change Build system from gradle to internal. it will resolve your error.
But it is ok for just testing your game if you are building for google play store then should build your game with gradle build.
To build with gradle you should follow some step
1. go to build setting -> player setting -> publishing setting
In publishing setting you should setup your keystore here you can create a new key or use existing key.
2. Sometimes gradle build failed also occur because of minimum API level so go in build setting -> player setting -> other setiing
in other setting you will find minimum API level try to change this API level to Android 4.4 or 5.0
if you are using newer version of unity and API level is not present in other setting than leave it.
3. third and main reason of gradle build failed is gradle is not installed correctly so just go to file explorer and click on window drive
click local user name (this is whatever is your name in computer)
here you will find ".gradle" folder.
delete this folder and now now build your project and make sure your pc is connected to internet because unity will download the correct gradle version according to unity version so don't need to worry about anything just remember you arfe connected to network.
After following these step you can build your gradle project.