How to solve Unity "Gradle build failed"?
When I tried build Unity project for Android, it reported "Gradle build failed". I tried using VPN and using another repository(based in China where the Gradle connection is not working well), but still the same errors.
I checked the log(see following), one line says it tries to "Connect to 192.168.1.4:1125 [/192.168.1.4]", which seems suspicious. My building PC is 192.168.1.2, and it's connected directly to a fiber optic modem, which is 192.168.1.1. The 192.168.1.4 is another wifi modem connected to the fiber optic modem, and it should has nothing to do with my PC's internet connection.
Why does Unity try connecting a device that's not related when building Gradle? Any suggestions on how to solve this building failure? Thank you!
A problem occurred configuring project ':launcher'.
> Could not resolve all artifacts for configuration ':launcher:classpath'.
> Could not resolve com.android.tools.build:gradle:4.0.1.
Required by:
project :launcher
> Could not resolve com.android.tools.build:gradle:4.0.1.
> Could not get resource '404'.
> Could not GET '404'.
> Connect to 192.168.1.4:1125 [/192.168.1.4] failed: Connection timed out: connect
modified baseProjectTemplate:
Solution 1:
I've solved it. Find the "gradle.properties" file at "C:\Users\xxx\.gradle", comment out the systemProp.xxxx like this: