Android developer tools for Android Studio----Gradle

Source: Internet
Author: User
Tags jcenter

Introduction to the. gradle file

In an Android Studio project, there will be multiple. gradle files. Where there is a Build.gradle file and a settings.gradle file in the project directory; a build.gradle file exists for each module.

A basic explanation of Gradle


//Top-level build file where can add configuration options common to all sub-projects/modules.Buildscript {//To set the code to drive the build processrepositories {Jcenter ()//declaration using the MAVEN repository. In the old version, here is Mavencentral ().             //Mavencentral (): Indicates dependency is obtained from the Central Maven 2 warehouse.             //Jcenter (): Indicates dependency is obtained from Bintary's Jcenter Maven repository.             //**mavenlocal () * *: Indicates dependency is obtained from the local Maven repository. } dependencies {//declared using the Android Studio gradle plugin version. General upgrade as or import from        you need to modify the following Gradle version when you build the project in//eclipse. Classpath' '        //Note:do not place your application dependencies here; they belong        //In the individual module Build.gradle files}}allprojects {//Set up the build process for each module. In this example, each module is set to use a    //MAVEN warehouse dependent. repositories {Jcenter ()}}

The default project directory contains the contents of the Settings.gradle file as above. It is possible that by default, the Settings.gradle file under the project directory does not exist and you can create it yourself.

? Include ': App ': Indicates that there is a module named app under current project. :

If you need to introduce a module that is not under the project's root directory
Can be set as follows

include‘:app2‘project(‘:app2‘new File(‘path/to/app2‘)

Next, we'll talk about the Build.gradle file in module

Apply plugin:' 'Android {Compilesdkversion ABuildtoolsversion"22.0.1"Defaultconfig {ApplicationID"Com.hzchou.myapplication"Minsdkversion -Targetsdkversion AVersioncode1Versionname"1.0"} buildtypes {release {minifyenabledfalseProguardfiles Getdefaultproguardfile (' Proguard-android.txt '),' '}}}dependencies {Compile Filetree (dir:' Libs ', include: [' *.jar ']) Compile' '}

? Apply plugin: ' ':
Represents the use of the plug-in. That is to say, this is an Android application module. says this is an Android library module.
? Android:
Configure the parameters required for all Android build processes.
? Compilesdkversion:
The SDK version used for compiling.
? Buildtoolsversion:
The version of the tool used to compile the Gradle project.
? Defaultconfig:
Android Project default settings.
1. ApplicationID: Application package name.
2. Minsdkversion: Minimum supported Android version.
3. Targetsdkversion: Target version. It should actually be the Android version of the test machine under the test environment.
4. Versioncode: Version number.
5. Versionname: Version name.
? Buildtypes:
The compilation type. There are two default: Release and Debug. We can add our own buildtypes here, which we can see in the Build variants panel
? Minifyenabled:
Whether to use confusion. In the old version for Runproguard, the new version of the name, because the new version supports the removal of unused resource files, and Runproguard this name is not appropriate.
? Proguardfiles:
Using a confusing file, you can use multiple confusing files. In this example, the use of theSDKThe Proguard-android.txt file in the current module directory and the file.

? Dependencies
The dependency used to formulate the reference.
1. Compile Filetree (dir: ' Libs ', include: [' *.jar ']):
References all. jar files in the Libs folder under the current module directory.
2. Compile ' ':
Reference 21.0.3 version of APPCOMPAT-V7 (the commonly used v7* Library project).

Android developer tools for Android Studio----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: 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.