studio 版本统一管理记录

 1.studio 版本统一管理,现在project中的build.gradle添加ext{}。



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

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

/** 统一管理版本号 **/
ext{
    // 用于编译的SDK 版本
    compileSdkVersion_all = 28
    //  最低支持Android版本
    minSdkVersion_all = 21
    //  目标版本
    targetSdkVersion_all = 28
    //  用于Gradle编译项目的工具版本
    buildToolsVersion_all = '24.0.2'
    // 版本编号
    versionCode_all = 1
    // 版本号
    versionName_all = '1.0.0'
    /** Android 依赖 jar 包**/
    supportV7_all = 'com.android.support:appcompat-v7:28.0.0'
    constraint_layout_all = 'com.android.support.constraint:constraint-layout:1.1.3'
    junit_all = 'junit:junit:4.12'
    support_runne_all = 'com.android.support.test:runner:1.0.2'
    support_espresso_all = 'com.android.support.test.espresso:espresso-core:3.0.2'
    /** 第三方框架   **/
}

2.在APP中的build.gradle中引用。

apply plugin: 'com.android.application'

android {
    compileSdkVersion rootProject.ext.compileSdkVersion_all
    defaultConfig {
        applicationId "com.gdvictor.technologyproject"
        minSdkVersion rootProject.ext.minSdkVersion_all
        targetSdkVersion rootProject.ext.targetSdkVersion_all
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation rootProject.ext.supportV7_all
    implementation rootProject.ext.constraint_layout_all
    testImplementation rootProject.ext.junit_all
    androidTestImplementation rootProject.ext.support_runne_all
    androidTestImplementation rootProject.ext.support_espresso_all
}
发布了44 篇原创文章 · 获赞 15 · 访问量 9万+

猜你喜欢

转载自blog.csdn.net/m0_37039192/article/details/84333342