Android Studio native supports the use of Gradle to build projects, defining the process of project construction with the dynamic language groovy, and avoiding the tedious definition of build.xml files.
However, when used, there is a huge flaw. As Android studio upgrades, it may be accompanied by a gradle version of the upgrade, Gradle will produce several versions.
In order to ensure that the program does not cause problems due to gradle version, and Gradle wrapper, its role is to allow the project to bind a gradle version, when we import the project, will automatically download the corresponding Gradle version.
Here's the problem.
This causes us to download the corresponding Gradle version if the current computer does not have a gradle version of the project configuration when opening other projects. But Gradle's binary package is larger, plus the link is foreign server, leading to the domestic basic difficult to download down, this time will appear below the situation.
You don't know exactly as dead, or what it does in the background ... You can either have a temper or just turn off the as, and must be forced off. This is a very unfriendly thing to do. In fact, the reason that you are stuck here is because the Gradle package is downloaded from the server in the background. And this gradle packet often has a few 10 trillion, in the network environment is not very good circumstances, it may take a long time to complete. Obviously, we don't have so much time to spend here, we need to find a way to solve it.
Solution of the way one
When you install the Android Studio and SDK, you must install at least one gradle, and you can query the Gradle version by creating a new project.
Local Gradle version path also know, open the settings interface
There are also a few parameters to record, this is the SDK matching, the imported project to compile the SDK version of the computer also need to have.
Remember these parameters and then change the parameters you want to import into the same as the current parameter, and you can import the project normally.
See How to modify :
-Xxx-project/.idea/gradle.xml File:
Add or modify the Gradlehome parameter before <option name= "Gradlehome" value= "/>
-Xxx-project/gradle/wrapper/gradle-wrapper.properties File:
The gradleversion-all.zip in front of the distributionurl=https\://services.gradle.org/distributions/gradle-
-Xxx-project/build.gradle File:
Classpath ' Com.android.tools.build:gradle: Front android Plugin Version ' (this is the entire project configuration)
-Xxx-project/app/build.gradle File:
Modify the compile SDK version and build Tools version parameters. (This is a single module configuration, each module in project needs to be modified)
After you have modified it, you can import it normally.
If the computer is disconnected, you can import the project directly, but the project does not run correctly, or you need to modify these parameters to compile correctly.
Solution Two
The main problem above is that the Gradle version is not downloaded, we can download the specified Gradle version separately.
You can view the Gradle version of the project Dependencies First,
Then to find the appropriate version of the download, download the address: Https://pan.baidu.com/s/1hsgDmXQ
Windows defaults to put the downloaded files in the C:\Users\xxx\.gradle\wrapper\dists directory
Mac defaults in/users/apple/.gradle/wrapper/dists/
Each version of the ZIP package is placed under the appropriate version path, such as:
The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.