Android 優雅的使用 gradle

gradle 管理 app 版本的時候不夠清晰,看過其餘人定義的gradle.properties, 或者新建gradle,再引入apply from: '.***.gradle'android

下面是比較簡單明瞭的方式之一

build.gradle (./app)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}"
..
}

須要注意的是 compile 的是雙引號gradle

相關文章
相關標籤/搜索