目 录CONTENT

文章目录

Android gradle自动化打包

Stars-one
2022-01-14 / 0 评论 / 0 点赞 / 3 阅读 / 0 字
import groovy.json.JsonSlurper

plugins {
    id 'com.android.application'
}

//获取当前时间
def releaseTime() {
    return new Date().format("yyyyMMdd", TimeZone.getTimeZone("UTC"))
}

def jsonFile = file('version.json')
def versionInfo = new JsonSlurper().parseText(jsonFile.text)
def fileName = releaseTime()+ "_"+versionInfo.versionCode
android {
    compileSdkVersion 30
    buildToolsVersion '28.0.3'

    defaultConfig {
        applicationId versionInfo.applicationId
        minSdkVersion 19
        targetSdkVersion 31
        versionCode versionInfo.versionCode
        versionName versionInfo.versionName

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    //签名配置
    signingConfigs {
        debugConfig {
            storeFile file("xuexibao.keys")
            storePassword "tyky\$123456"
            keyAlias "tyky_czing"
            keyPassword "tyky\$123456"
        }
        releaseConfig {
            storeFile file("xuexibao.keys")
            storePassword "tyky\$123456"
            keyAlias "tyky_czing"
            keyPassword "tyky\$123456"
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            //自动签名的关键!!
            signingConfig signingConfigs.releaseConfig
        }
    }


    android.applicationVariants.all { variant ->
        variant.outputs.all {
            outputFileName = "base_${fileName}.apk"
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}


dependencies {
    implementation 'androidx.appcompat:appcompat:1.1.0'
    //图片,视频,音频选择 https://github.com/LuckSiege/PictureSelector
    implementation 'io.github.lucksiege:pictureselector:v2.7.3-rc08'
    //Glide
    implementation "com.github.bumptech.glide:glide:4.12.0"
    //权限申请
    implementation 'com.yanzhenjie:permission:2.0.3'

    // Android的工具类   https://github.com/Blankj/AndroidUtilCode/blob/master/lib/utilcode/README-CN.md
    implementation 'com.blankj:utilcodex:1.30.6'
    //日志输出    https://github.com/ZhaoKaiQiang/KLog
    implementation 'com.github.zhaokaiqiang.klog:library:1.6.0'

}
0

评论区