"Android Studio Discovery Trail Series" VII: Android Project building System-Gradle

Source: Internet
Author: User
Tags jcenter

Guo Xiaoxing
Weibo: Guo Xiaoxing's Sina Weibo
Email:[email protected]
Blog: http://blog.csdn.net/allenwells
Github:https://github.com/allenwell

The project building system for Android Studio is Gradle.

What is Gradle?

Gradle is based on the Groovy language and is oriented toward Java applications. Automated building tools based on DSL (domain-specific language) syntax.

What are the advantages of gradle?

  1. Gradle support for multi-project construction is excellent, and engineering relies on Gradle's first citizens.
  2. Gradle support for local builds.
  3. Support multi-mode dependency management: Includes jars or dirs from maven remote repositories, nexus, ivy warehouses, and local file systems
  4. Gradle is the first built-in integration tool that has a good compatibility dependency with Ant, Maven, ivy, and integration.
  5. Easy migration: Gradle works with any structure (Gradle can adapt to any structure you have.). You can build original and gradle projects in parallel on the same development platform. It is often required to write related tests to ensure the similarity of the plug-ins developed, and this migration can be less disruptive and as reliable as possible. This is also the best practice for refactoring.
  6. The overall design of Gradle is a language-oriented, rather than a rigid framework.
  7. Free Open Source

What features does the Gradle offer?

  1. A switchable, contract-based build framework like Maven that never locks you (contract is better than configuration)
    Switchable, build-by-convention frameworks a la Maven. But we never lock you in!
  2. Powerful support for multi-project construction
  3. Powerful dependency management (Apache Ivy based) for maximum convenience to build your project
    Language for dependency based programming
  4. Fully support existing MAVEN or Ivy warehouse infrastructure
  5. Support for transitive dependency management, without the need for remote warehouses and pom.xml and Ivy profiles
  6. Built on groovy scripting with a build script written in the groovy language
  7. With a wide range of domain models support your build a rich domain model for describing your build.

In Android Studio, Gradle is comprised of a top-level profile and other module configuration files, as shown in:

Let's take a look at these files in turn.

A gradle top-level configuration file
fileaddto all sub-projects/modules.buildscript {    repositories {        /* 存储库jcenter,也可以配置moven */        jcenter()    }    dependencies {        /* 依赖的Gradle版本 */        ‘com.android.tools.build:gradle:1.2.3‘        // NOTE: Do not place your application dependencies here; they belong        // in the individual module build.gradle files    }}allprojects {    repositories {        /* 所有项目的存储库 */        jcenter()    }}
Two gradle module configuration file
Apply plugin:' Com.android.application 'Android {Compilesdkversion A//Highest API levelBuildtoolsversion"22.0.1"//Compile tool version numberDefaultconfig {//default configurationApplicationID"Com.allenwells.myapplication"//Application package nameMinsdkversion the//Minimum API levelTargetsdkversion A//Compile API levelVersioncode1//Version numberVersionname"1.0"//Version name} buildtypes {//Build TypeRelease {//Official version configurationMinifyenabledfalseProguardfiles Getdefaultproguardfile (' Proguard-android.txt '),' Proguard-rules.pro '}//Confusing configuration files} sourcesets {main {jnilibs.srcdirs =[' Libs ']}}}dependencies {//Dependent configurationCompile Filetree (dir:' Libs ', include: [' *.jar ']) Compile' com.android.support:appcompat-v7:22.1.1 '}

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

"Android Studio Discovery Trail Series" VII: Android Project building System-Gradle

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.