Http://www.androidchina.net/5527.html
Android Studio has a huge advantage over eclipse ADT.
Android Studio native supports building projects using Gradle, using dynamic language groovy to define the process of building a project, avoiding the tedious definition of build.xml files.
However, when used, there is a huge flaw. As Android studio upgrades may accompany the Gradle version of the upgrade, Gradle will produce several versions.
To ensure that the program does not cause problems due to the Gradle version, but also produces a gradle Wrapper, its role is to have the project bound to a gradle version, when we import the project, will automatically download the corresponding Gradle version.
Then, and, egg. Here's the problem.
This causes us to open other projects, if the current computer does not have the Gradle version of the project configuration will download the corresponding Gradle version. However, the Gradle binary package is larger, plus the link is a foreign server, resulting in the domestic basic difficult to download down, this time after the following situation will appear.
You don't know if it's as dead, or what it does in the background ... Either be resistant to the temper, or just turn off as, and it must be forced to close. This is a very unfriendly thing to do. In fact, the reason for this is that the Gradle package is downloaded from the server in the background. This Gradle package often has a few 10 trillion, in the network environment is not very good situation, 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 One
When you install Android Studio and SDK, you must have at least one gradle, and you can query to the Gradle version by creating a new project.
Local Gradle version path also know, open the settings interface
There are a few parameters to record, which is matched with the SDK, the imported project in the compilation of the SDK version of this machine should also have.
Remember these parameters, and then change the parameters to import the project to match the current parameters, you can import the project normally.
To see how to modify:
- xxx-project/.idea/gradle.xml文件:添加或修改<option name="gradleHome" value="前面的GradleHome参数" />- xxx-project/gradle/wrapper/gradle-wrapper.properties文件:distributionUrl=https\://services.gradle.org/distributions/gradle-前面的gradleVersion-all.zip- xxx-project/build.gradle文件:classpath ‘com.android.tools.build:gradle:前面Android Plugin Version‘ (这个是整个project的配置)- xxx-project/app/build.gradle文件:修改Compile SDK Version和Build Tools Version参数。(这个是单个module的配置,project中每个module都需要修改)
After the modification, you can import it normally.
If the computer is disconnected, you can import the project directly, but the project will not work properly, or you need to modify these parameters to compile properly.
Solution Two
The main problem above is that the Gradle version cannot be downloaded, and we can download the specified Gradle version separately.
You can view the Gradle versions of the project Dependencies First,
Then go to the appropriate version for download.
Https://pan.baidu.com/s/1pLEkm4F#path=%252F
Windows defaults to placing downloaded files in the C:\Users\xxx\.gradle\wrapper\dists directory
Mac defaults to/users/apple/.gradle/wrapper/dists/
Each version of the ZIP package is placed under the corresponding version path, such as:
Android Studio solves the problem of importing items very slowly