When you create a new Android Gradle project in Android Studio, connect Refused:connect or stuck in building project ... or refreshing XXX Gradle project
===
The reasons are:
Gradle in the creation of the need for networking, otherwise it will fail, although I can network, but cannot access the Gradle site or download, so no.
Thanks to the great gfw, two ways of
1.Using proxies
---
Turn over the wall, you can.
- Start XX Gate
- HTTP proxy, manual proxy, setting, Android Studio, configration Select HTTP
```
hostname:127.0.0.1
Port number:8580
```
Port number depends on local port setting of XX Gate
- Restart as when Setup is complete, re-sync project with Gradle files
* * Advantages: * *The other functions that need to be turned over to the wall can also be used
* * Cons: * *It's a little tricky to configure.
2.Using Gradle offline Packages
---
When you create a new project, you can see
```
Refreshing xxx gradle project
gradle Download Http://services.gradle.org/distributions/gradle-1.12-all.zip
```
That is, stuck in the Gradle installation package download, then we put the offline package down, put it in the right place is good
- The right location and the right version
gradle Download Locations for each operating system
> Windows:c:\documents and Settings\<user name>\.gradle\wrapper\dists\
> linux:~/.gradle/wrapper/dists/
> mac:~/.gradle/wrapper/dists/
version
Although the download of as is stuck, a storage directory such as \gradle-1.12-all\2apkk7d25miauqf1pdjp1bm0uo has been created in the Dist directory. From the front can also be seen to download the offline package is Gradle-1.12-all.zip
- Download, put Gradle-1.12-all.zip under \gradle-1.12-all\2apkk7d25miauqf1pdjp1bm0uo, restart as, reopen project
* * Advantages: * *Do not configure each new Gradle project again
* * Cons: * *Gradle storage directory in the system directory, the reload system may have to be reconfigured
3.Using Gradle Offline package (ii)
---
Offline packages can also be placed in a custom directory, such as I put under the D:\DevEnv\gradle, and then
- Select Use local Gradle distribution in Project-level Settings, Gradle-Settings,
- Fill in the custom storage directory in Gradle home.
- Restart as to reopen the project
* * Advantages: * *Custom storage directory for easy management
* * Cons: * *Because it is project-level settings, each new Gradle project must be configured once