android studio cradle local configuration

I just encountered a lot of pits from eclipse to android studio. Today, I will help you fill in the pits.

Since May 16, 2013, at the I/O conference, Google launched a new Android development environment - Android Studio, and improved the developer console, adding five new functions, Google has completely abandoned eclipse turned to as!

We know that as chooses the best build tool gradle

Gradle: Gradle is a project automation build tool based on Apache Ant and Apache Maven concepts. It uses a Groovy-based Domain-Specific Language (DSL) to declare project settings, ditching the cumbersome XML-based configuration.

Mainly for Java applications. Currently its supported languages ​​are limited to Java, Groovy and Scala, with plans to support more languages ​​in the future. The future is broad
Entering the topic below is mainly to configure gradle and android gradle plugins in as. Note that gradle and (android gradle plugin) must not be confused, and the two are different.
The android gradle plugin depends on gradle. The latest gradle version is 2.1.3
1.gradle configuration
When we set gradle to select "use defalut gradle wrapper(recommended)" under gradle under setting, as will go to gradle according to the configuration in {project.dir}\gradle\wrapper\gradle-wrapper.properties file
 
When we use as to build an android project, when configuring gradle, we must configure the gradle package in the {project.dir}\gradle\wrapper\gradle-wrapper.properties file, and the configured gradle must be in the cache directory ("User home directory/.gradle /wrapper/dists/gradle-*.*.*”) or the corresponding version exists in the gradle directory under the as installation directory.
For example my computer: C:\Users\dsfg\.gradle\wrapper\dists\gradle-2.4-all
1
2
3
4
5
6
#Wed Apr 10 15:27:10 PDT 2013
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper /dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper /dists
distributionUrl=https\: //services .gradle.org /distributions/gradle-2 .2.1-all.zip

If the gradle of this configuration exists in the directory "user home directory/.gradle/wrapper/dists/..", as will not go to https\://services.gradle.org/distributions/gradle-2.2.1-all .zip to download, as will use the cache in this directory, if there is no gradle in the directory, as will go to the site to download according to the version of gradle to "user home directory/.gradle/wrapper/dists/gradle- 2.2.1-all" directory.

If you select "use local gradle distribution", it means that the local gradle is used, and the local gradle is in the gradle directory under the main directory of as, such as my computer D:\android development environment\android-studio-ide -143.2739321-windows\android-studio\gradle\gradle-2.10, instead of going to the cache directory "user home directory/.gradle/wrapper/dists/gradle-*.*.*" to find it.

"global gradle setting" we don't consider for now

2. Configuration of android gradle plugin

What I discussed above is the gradle configuration. Let's talk about the configuration of the android gradle plugin. We set the android gradle plugin through the main project's build.gradle (not the module's build.gradle)

in build.gradle

1
2
dependencies {
     classpath  'com.android.tools.build:gradle:2.0.0' }

  The version of the android gradle plugin configured here is 2.0.0. Once again, we must remember that the gradle version and the version of the android gradle plugin are not the same thing at all and cannot be confused.

The following is the version relationship correspondence table of android studio version, gradle version, and android gralde plugin

 The official documentation is attached below: http://tools.android.com/tech-docs/new-build-system/version-compatibility

  See  http://tools.android.com/tech-docs/new-build-system for all android gradle plugin versionsfeatures

  Friends who want to know more about Gradle's core language Groovy can click the link below, which introduces the groovy domain-specific language in detail

  Gradle build Android application groovy - DSL domain specific language

 

 
 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326398912&siteId=291194637