How to fix Android Gradle Build failed error in unity

 If yoiu are seeing gradle build failed when building your game in unity showing following message
Gradle build failed


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.

player setting unity


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.

google play publishing setting in unity


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.


Player setting in unity



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 

file explorer


    click users


click local user name (this is whatever is your name in computer)

here you will find ".gradle" folder. 

.gradle in pc



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.


Popular posts from this blog

Positioning GameObjects in unity editor

Creating count down timer in unity by c# script

Changing Image in unity by C# script