Solve the problem that Android Studio build grale keeps stuck

       每个安卓新人开始使用Android stduio导入别人项目时都会遇到Gradle build running一直卡着不动,这是因为后台正在下载和项目对应的gradle,但是由于谷歌的一道墙,所以会导致下载缓慢。个人刚开始使用Android stduio时也是相当的困惑,所谓实践出真知,自己动手解决问题才是彻底的解决问题。

Let’s solve this problem

method one:

gradle

**
One is the default gradle download path, which means that every gradle you download in the system will be downloaded to the default gradle. If not, go to the gradle official website to download the corresponding compressed package, and be careful not to unzip it. The other is the path set by yourself. Of course, you can copy the downloaded package into it. If you use the path set by yourself for the gradle project, please choose the second one.

Method Two:

**
You can enter the build.gradle configuration file to modify the parameters corresponding to your Android studio before importing the project.
The following parameters should be remembered:

Gradle version:4.1

android plugin version:2.3.3

D:\androidStdio\Android Studio\gradle\gradle-4.1


C:/Users/Administrator/.gradle


compile Sdk version:API 24: Android 7.0 (Nougat)

Build Tools Version:25.0.0



来看看怎么修改:
- 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都需要修改)
修改完了,就可以正常导入了。
如果电脑断网,可以直接导入项目,但是项目不能正常运行,还是需要修改这些参数才能正常编译。

Guess you like

Origin blog.csdn.net/yjh_SE007/article/details/78442208