Explain in detail some problems about installing and gradle in Android studio

It has been almost a year since I started using Android studio. When I first started using Android studio, it was still version 1.2. At that time, due to the domestic wall, the download steps of SDK were blocked and could not be installed.

The latest version seems to have no such problem, but make complaints about the latest 2.2.3 update. In the SDK included in the installation package of this version, the build tools version is 25.0.2, and the minimum supported gradle version is 3.3. However, the gradle version included in the installation package is 3.2, so you can't create any complete projects with the installation package alone. Even the included HelloWorld project will report errors, which has caused a lot of fresh meat when the Department recruits new projects recently.

Now that I have explained the reason, the solution is obvious:

(1) Download the SDK and earlier build tools. I won't talk more about how SDK manager sets up the image. You can find this casually

(2) Update gradle. To be honest, I'm not very clear about its internal structure. I only know that it will cause many problems when updating as and project cooperation. (yes, I was cheated out of my experience)

So let's talk about gradle.

First of all, this thing is mainly because it is not updated with the SDK. It belongs to the as itself. If there is no gradle version specified by the project in your computer, as will download it by default. Due to the wall, the download will be extremely slow or even motionless. If there is a reliable VPN, you can set up an agent for as to perfectly solve the problem of wall. But a student dog like me will still save the money that can be saved. There are ways not to spend money. Generally, I won't spend money. So how to solve it without VPN?

First of all, since the gradle version is specified by the project, we just need to modify the gradle configuration of the project and change it to our existing gradle?

Generally speaking, the higher version of gradle will be compatible with the lower version of gradle. For projects using a higher version of gradle, switching to a lower version of gradle is not necessarily a problem (at least I haven't met it). In order to adapt the gradle of this project to the new as, we need to modify three files, namely the three files in the following figure, after you get a project of others or your own old as:

1. Build.gradle of the total project

As shown in the figure above, notice the first item in dependencies, and finally gradle: 2.3.1 (the second item is an open source database tool class realm)

This 2.3.1 is the version number of as, and the old version of as will be the version number of the old version.

2. Build.gradle in app directory

Generally, you don't need to modify this, but if there is a build tools problem (such as the problem of updating 2.2.3 mentioned at the beginning), you need to modify the build tools version set in this file

3、gradle-wrapper.properties

This file is in the grade / wrapper / directory of the project. The key is this sentence

Gradle-3.3-all.zip refers to specifying gradle version 3.3. Just change 3.3 to the version available on the computer.

As for which versions of gradle are available on the computer, on the one hand, you can refer to the file in the project you normally use, and you can also check under the gradle file in the as directory

As shown in the figure, gradle versions 3.0 to 3.4 should be available. All versions contained in the folder should be available.

Then, if you don't want to change these every time you get the project, another way is to update the gradle yourself and put the gradle in the gradle folder under the as directory. In this way, if you have the specified gradle locally, the as will not try to download through the wall.

A resource website is posted below, which has a wide range of Android development tool download resources. The above-mentioned gradle can also be downloaded here, and the speed is very fast.

http://www.androiddevtools.cn/

Well, that's all for the time being. Let's talk about stepping on any pit in the future.

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
分享
二维码
< <上一篇
下一篇>>