Dowemo
0 0 0 0

1 problem

( 1 ) android first opens a project giant slow?
( 2 ) manually configuring a manual home, why isn't it valid.
( 3 ) I've already downloaded a gradle, configured a gradle home, why do I open the project or download it automatically.

Introduction to 2

( 1 ) 's android studio knows how to use the gradle.
A as that's used by an project is determined by the following file in our project:

% 7byour project % 7D/gradle/wrapper/gradle-wrapper. Properties.

The contents of the file are as follows:

#Mon Sep 28 16:15:03 CST 2015distributionBase=GRADLE_USER_HOMEdistributionPath=wrapper/distszipStoreBase=GRADLE_USER_HOMEzipStorePath=wrapper/distsdistributionUrl=https://services.gradle.org/distributions/gradle-2.4-all.zip
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

Last row. distributionUrlA gradle version of this project is determined, which means that different projects can use a different version of gradle, which is why changes to the home fail. So how do we know what version of the package is. The answer is the following link:

Gradle download address: https://services. Gradle. org/distributions/.

So you'll be able to modify the subsequent gradle version as long as you've the link on it.

( 2 ) where to save the?
Gradle is shared by everyone, and of course it'll not be placed in the project file ( not available ), and as will store it in the following directory:
linux:

~/. gradle/wrapper/dists.

windows :

C: users % 7buser name % prematurely. Gradlewrapperdists.

Open this directory to see the downloaded gradle version.

这里写图片描述

When android studio opens a project, it reads first Gradle-wrapper. Properties. The file, which knows which version of the project is needed, and then saves the gradle folder. Gradle_user_home To find a gradle that doesn't exist, there's no way to go. distributionUrlDownload
Figure out the process, now if it isn't clear, why it'll be slow for the first time to open a project because as will download it. Why do I've to download a gradle, also specify a gradle directory, or it'll be downloaded automatically, because you don't have a pair of places. Now look back to the project profile. gradle/wrapper/gradle-wrapper. Properties. It's a big.

3 configuration method for

Now that you know the principle, it also knows why the card is in the download, and then we download the gralde and then configure it.
( 1 ) modify the gradle wrapper. Properties.
Modify the distributionUrl in the gradle wrapper. Properties to the version we want, just change the later version, and don't change the previous section. See the following links for a specific ve ion:

Gradle download address: https://services. Gradle. org/distributions/.

( 2 ) open the project
At this time as will automatically download gradle and create a directory. Go directly to the android studio and exit, because this step is to get the download directory that as automatically creates, and navigate to the following directory:
linux:

~/. gradle/wrapper/dists.

windows :

C: users % 7buser name % prematurely. Gradlewrapperdists.

In the gradle ve & ion folder, you'll find a folder that takes gradle2. 4 as an example, as follows:
这里写图片描述

这里写图片描述

这里写图片描述

( 2 ) download gradle
From the above gradle download address, download a 4-all for the corresponding version, in this case, for 2. Zip, then remove the gradle 2. 4-all. Zip. Part file from the above image to copy the downloaded gradle 2. 4-all. Zip to the previous string in the above string. So we've skipped the download.

( 3 ) android studio, open the project, ok, and open it.

version of

The gradle and gradle are two separate things, the gradle version is determined by the project 's outermost build. Gradle file.
App/build. Gradle:

buildscript {
 repositories {
 jcenter()
 }
 dependencies {
 classpath 'com.android.tools.build:gradle:2.1.0'//NOTE: Do not place your application dependencies here; they belong
//in the individual module build.gradle files
 }
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

After you modify the gradle version, sync the code.




Copyright © 2011 Dowemo All rights reserved.    Creative Commons   AboutUs