Android uses gradle elegantly

It is not clear enough when gradle manages the app version. I have seen gradle.properties defined by others, or create a new gradle, and then introduce apply from: '.***.gradle'

Here is one of the simpler and clearer ways

build.gradle (./app)

apply plugin: 'com.android.application'
apply plugin: 'realm-android'

ext{
    COMPILE_SDK_VERSION     =   25
    TARGET_SDK_VERSION      =   25
    MIN_SDK_VERSION         =   19
    SUPPORT_V4              =   "25.3.+"
    SUPPORT_V7              =   "25.3.+"
    VERSION_CODE            =   2
    VERSION_NAME            =   "0.1.0"
}

android {
    compileSdkVersion COMPILE_SDK_VERSION
    defaultConfig {
....

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile(name: 'MPChartLib-release', ext: 'aar')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })

    compile(name: 'ljdatepicker', ext: 'aar')
    compile "com.android.support:support-v4:${SUPPORT_V4}"
    compile "com.android.support:appcompat-v7:${SUPPORT_V7}"
    compile "com.android.support:design:${SUPPORT_V7}"
    compile "com.android.support:cardview-v7:${SUPPORT_V7}"
..
}

It should be noted that the compile is double quotes

Guess you like

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