Android studio import project is very slow solution

Android studio natively supports the use of gradle to build projects, and uses the dynamic language groovy to define the project construction process, avoiding the cumbersome definition of the build.xml file.

However, when used, it has great defects. When Android studio is upgraded, it may be accompanied by the upgrade of gradle version, and gradle will produce several versions.

In order to ensure that the program will not cause problems due to different gradle versions, a gradle wrapper is generated. Its function is to bind the project to a gradle version. When we import the project, we will automatically download the corresponding gradle version.

Here comes the problem

This causes us to download the corresponding gradle version when opening other projects if the current computer does not have the gradle version configured for the project. However, due to the large binary package of gradle and the link to foreign servers, it is difficult to download it in China. At this time, the following situation will appear.

You don't know whether the as is dead or what it really does in the background... Either be patient or turn off the as directly, and it must be forced to turn off. This is very unfriendly. In fact, the reason why it is stuck here is because the gradle package is downloaded from the server in the background. The gradle package often has tens of megabytes. In the case of poor network environment, 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 1

When you install Android studio and SDK, you must install at least one gradle. At this time, you can query the gradle version by creating a new project.

You should also know the path of the local gradle version. Open the setting interface

There are several parameters to be recorded, which match the SDK. The SDK version compiled in the imported project should also be available locally.

Remember these parameters, and then change the parameters of the project to be imported to be consistent with the current parameters to import the project normally.

Let's see how to modify:

-XXX project /. Idea / gradle.xml file: add or modify < option name = "gradlehome" value = "previous gradlehome parameter" / >

-XXX project / gradle / wrapper / gradle wrapper.properties file: distributionurl = HTTPS \: / / services.gradle.org/distributions/gradle - gradversion-all.zip in front

-XXX project / build.gradle file: classpath 'com. Android. Tools. Build: gradle: Android plugin version' (this is the configuration of the whole project)

-XXX project / APP / build.gradle file: modify the compile SDK version and build tools version parameters. (this is the configuration of a single module, and each module in the project needs to be modified)

After modification, you can import normally.

If the computer is disconnected, you can import the project directly, but the project cannot run normally. You still need to modify these parameters to compile normally.

Solution 2

The main problem above is that the gradle version cannot be downloaded. We can download the specified gradle version separately. First, you can view the gradle version that the project depends on,

Then find the corresponding version to download. Download address: https://pan.baidu.com/s/1hsgDmXQ

By default, windows puts the downloaded files in the directory C: \ users \ XXX \. Gradle \ wrapper \ dists

The MAC defaults to / users / apple /. Gradle / wrapper / dists/

The zip package of each version is placed under the corresponding version path, such as:

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>