Statement: this text isn't self original, to organize the network data with some notes.

Reference: http://blog. Csdn. net/xukunhui2/article/details/50999591.

Gradle building system

Gradle is a dependency management tool, a dependency relationship is a new concept in android studio and gradle, to understand how they work, and how to.
Here are the files that you often use when configuring your android studio project. You create an android studio project that comes with two gradle scripts and some other profiles.

Project项目视图 Android项目视图

The illustration below is my project structure ( the project view on the left, the right to the android project view ):
The project view shows the location of the gradle file in the disk.
The android view puts all the modified profiles in the gradle scripts directory. The gradle script is the build script in the gradle build system. You can see these profiles here.

Now let's explore the effects of these files:

  • Local. Properties.
    Specifies where the android sdk is located, where its storage path is independent of the android studio installation location. If there are other android sdk directories, you can change its value again. You can also change configuration through the user interface of android studio, so it isn't recommended to modify the file itself.
    Changes in the user interface: > project structure ( shortcut key ctrl + alt + shift + s ) to change the sdk and jdk in this interface, which is specific to the project, so you can make another version of the sdk for this project, so you can make another version of the sdk for that project. It's important to note that the full jdk version specified by the jdk is specified, not just the jre version at runtime
  • Gradle. Properties.
    The default version of this version is completely commented out, but when you build your project, you can decide on a lot of gradle behavior. For example, # specifies the jvm arguments used for the daemon process. About the jvm 's parameters, only with gradle memory management.
  • At the top level build.
    The build. Gradle file located under the root directory is called the project file, typically without modifying the file. It has two references: Jcenter ( ). When you talk about the dependencies, you'll need to add some content to the .

 dependencies {

 classpath ''

 //NOTE: Do not place your application dependencies here; they belong

 //in the individual module build.gradle files


Here's a class path: Classpath 'com. Tools. Build: gradle: 1. 5. 0 'indicates the package name and current version of the gradle. In addition, you won't change this value. This value is generally rewritten automatically when you upgrade android studio.

  • Build in the app directory.
    Build. Gradle is the application 's build script, which is used to configure many configurations that are used to tell android 's build system, what? What's the minimum sdk? and other information. Here are a number of values that are originally in the androidmanifest. Xml manifest and are now configured under this file.

apply plugin: ''

android {

 compileSdkVersion 25

 buildToolsVersion "25.0.2"

 defaultConfig {

 applicationId ""

 minSdkVersion 23

 targetSdkVersion 25

 versionCode 1

 versionName "1.0"

 testInstrumentationRunner ""


 buildTypes {

 release {

 minifyEnabled false

 proguardFiles getDefaultProguardFile('proguard-android.txt'), ''




def getLayoutLibPath() {

 return "${android.getSdkDirectory().getAbsolutePath()}" + "/platforms/" +

 android.compileSdkVersion + "/data/layoutlib.jar"


dependencies {

 compile fileTree(include: ['*.jar'], dir: 'libs')

 androidTestCompile('', {

 exclude group: '', module: 'support-annotations'


 compile ''

 testCompile 'junit:junit:4.12'

 compile files('libs/basesdk.jar')


dependencies {

 provided files(getLayoutLibPath())


Application id: application, the globally unique string to indicate your application in the play store or other distribution channel.
Minsdkversion: configuring the minimum sdk ve ion
TargetSdkVersion: configuring the target sdk ve ion
CompileSdkVersion: compile sdk version
【 note 】: compiling sdk and target sdk versions must be relative to the sdk version api level installed on your computer, such as I.
BuildToolsVersion: the build tool for the project settings, which must be the latest version of android studio available to match, to see if this version is I & talled in sdk manager.
Dependencies: the dependencies of android studio, you might see one or more dependent relationships listed, which is a reference to the support library, such as:

compile ''

Represents a support library that references android, version 7, and this iteration is specifically for the api level, 23.

compile fileTree(dir: 'libs', include: ['*.jar'])

  • 1

Referring to the libs folder, theoretically, it should include a jar file under any library folder, as part of your application. In practice, I found that this is more reliable and specific application of jar files.

  • Proguard in the app directory. Pro.
    This file is used to manage the proguard tool to manage you to minimize and blur your android application package code and upload it to the app store.
  • Build directory under app directory
    It's a compiled directory, usually not to change it, such as buildconfig is a generated class, usually not to deal with him. R is another generated class, and doesn't go.

Dependency relationships are a new concept in android studio and gradle, and understand how they work, and how to use the gradle process is critical. These are the files that are often used when developing projects with android studio.

Copyright © 2011 Dowemo All rights reserved.    Creative Commons   AboutUs