Android gradle Profile

Android studio used gradle following brief introduction:

Gradle is a dependency management tool, based on the Groovy language, for Java-based applications, it abandoned the complicated variety of XML-based configuration, replaced based on specific areas of Groovy (DSL) language. Android Studio in the new project after a successful automatic download Gradle.
Gradle has several basic components:

1. gradle profile build.gradle entire project

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.0-alpha4'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
Under this Module the gradle profile 2.app folder, the entire project can be regarded as the most important gradle profile

apply plugin: 'com.android.application'

android {
    signingConfigs {
        ast {
            keyAlias 'AST.jks'
            keyPassword 'AST.jks'
            storeFile file('E:/YD_AST/AST.jks')
            storePassword 'AST.jks'
        }
    }
    compileSdkVersion 23
    buildToolsVersion "23.0.2"
    defaultConfig {
        applicationId "yundi.com.pos"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName '1.0.1'
        signingConfig signingConfigs.ast
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.ast
        }
        debug {
            signingConfig signingConfigs.ast
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    sourceSets {
        main {
            jniLibs.srcDirs = ['libs']
        }
    }
    productFlavors {
    }
}

android {
    useLibrary 'org.apache.http.legacy'
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.+'
    compile 'com.android.support:design:23.+'
    compile 'cn.finalteam:okhttpfinal:2.0.2'
    // 网络
    compile 'com.bigkoo:svprogresshud:1.0.2'
    // 加载框
    // 提示框
    compile 'me.drakeet.materialdialog:library:1.2.8'
    compile files('libs/baidumapapi_v3_5_0.jar')
    compile files('libs/locSDK_5.2.jar')
    // 图片加载
    compile 'com.facebook.fresco:fresco:0.8.1+'
    compile 'com.jcodecraeer:xrecyclerview:1.2.6'
    // 刷新
    compile files('libs/gson-2.2.4.jar')
    compile 'com.jakewharton:butterknife:7.0.1'
    compile files('libs/alipaySDK-20150610.jar')
    compile files('libs/libammsdk.jar')
    compile 'com.orhanobut:dialogplus:1.11@aar'
}

Beginning of the file gradle apply plugin is the latest version of the wording, the previous wording that apply plugin: 'android', or if the previous wording, please correct it.


buildToolsVersion this you need to install the local version of the job, a lot of people new to import third-party libraries, one reason for the failure is that the wrong version of the build version, this can be changed manually into your existing local version or open SDK Manager to download the corresponding version.


The application package name applicationId representatives, it is the latest wording, not here in more.


android 5.0 installed by default jdk1.7 start to compile


minifyEnabled (confusion) is the latest of grammar, a long time ago is runProguard, this also needs to be updated next.


proguardFiles This part has two sections, the first part of the file confusion on behalf of the android system default program, the file already contains the basic statement of the confusion, we removed a lot of things, this directory file in the / tools / proguard / proguard-android . txt, after a part of our project is to confuse the file in the custom directories in app / proguard-rules.txt, if you create a new project Studio 1.0 is the default file name is generated proguard-rules.pro, the name does not matter in this file you can declare some some confusion rules depend on third parties, it will be specifically mentioned later.


compile project ( ': extras: ShimmerAndroid ') This line is because there are other Module project, you can be understood as Android Library, due to the popularity of Gradle and improve remote warehouse, this dependence will gradually become very common, but you need to know this dependence.

The basic operation is to these two files. The following is a confusing document proguard-rules.pro

Specific confusing information, please click http://blog.csdn.net/u010090644/article/details/51132672






Published 40 original articles · won praise 19 · views 60000 +

Guess you like

Origin blog.csdn.net/u010090644/article/details/51132953