AndroidStudio gradle 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 provided developers The console has been improved, five new functions have been added, and Google has completely abandoned eclipse 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.
The following topics are mainly used 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
}\gradle\wrapper\gradle-wrapper.properties The configuration in the file goes to gradle




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

#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
This configured gradle exists if it 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 gradle does not exist in this directory as will go to the site and download it to the "user home directory/.gradle/wrapper/dists/gradle-2.2.1-all" directory according to the gradle version.

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





the configuration of 2.android gradle plugin for the time being. I discussed the gradle configuration

above . Let's talk about the configuration of the android gradle plugin. We pass the build.gradle of the main project project (not the module build .gradle) to set the android gradle plugin





in build.gradle

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, so they cannot be confused

.







android.com/tech-docs/new-build-system/version-compatibility

  For all android gradle plugin versions and features, see http://tools.android.com/tech-docs/new-build-system

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

  Gradle in detail build Android application groovy—DSL domain-specific language

Guess you like

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