import java.text.SimpleDateFormat import java.time.LocalDateTime plugins { id 'com.android.application' id 'kotlin-android' id 'kotlin-kapt' } static int formatTime() { LocalDateTime now = LocalDateTime.now() int year = now.year % 100 // 取年份的最后两位 int month = now.monthValue int day = now.dayOfMonth int hour = now.hour int randomNumber = new Random().nextInt(10) // 生成0到9之间的随机数 return Integer.parseInt(String.format("%02d%02d%02d%02d%d", year, month, day, hour, randomNumber)) } ext{ versionCode=Integer.parseInt(new SimpleDateFormat("yyMMddHH").format(new Date()) + 1) brandCode="034A" brandVersionCode=versionCode model="3015" } android { compileSdk 31 defaultConfig { applicationId "com.develop.foodcooking" minSdk 21 targetSdk 26 versionCode project.ext.versionCode versionName "${project.ext.model}.${project.ext.brandCode}.${project.ext.versionCode}" archivesBaseName = "cofar-cooking_${versionName}" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" javaCompileOptions { annotationProcessorOptions { arguments = ["room.schemaLocation": "$projectDir/schemas".toString()] } } kapt { arguments { arg("AROUTER_MODULE_NAME", project.getName()) arg("room.schemaLocation", "$projectDir/schemas".toString()) } } packagingOptions { pickFirst 'lib/armeabi-v7a/libc++_shared.so' } } flavorDimensions "platform" productFlavors { brandDefault { dimension "platform" applicationId "com.develop.foodcooking" buildConfigField("String", "UpdatePlatform", "\"normal\"") resValue("string", "app_theme", "@style/SplashTheme") buildConfigField("String", "model", "\"3015\"") buildConfigField("String", "brandCode", "\"0000\"") } brand034 { manifestPlaceholders = [channelName: "brand034"] dimension "platform" applicationId "com.develop.foodcooking" buildConfigField("String", "UpdatePlatform", "\"night\"") resValue("string", "app_theme", "@style/Splash034Theme") buildConfigField("String", "model", "\"3015\"") buildConfigField("String", "brandCode", "\"034A\"") } brand000ATuya { manifestPlaceholders = [channelName: "brand000ATuya"] dimension "platform" applicationId "com.develop.foodcooking" buildConfigField("String", "UpdatePlatform", "\"normal\"") resValue("string", "app_theme", "@style/SplashTheme") buildConfigField("String", "model", "\"3015\"") buildConfigField("String", "brandCode", "\"000A\"") } brand058A { manifestPlaceholders = [channelName: "brand058A"] dimension "platform" applicationId "com.develop.foodcooking" buildConfigField("String", "UpdatePlatform", "\"normal\"") resValue("string", "app_theme", "@style/SplashTheme") buildConfigField("String", "model", "\"3015\"") buildConfigField("String", "brandCode", "\"058A\"") } brand012ATuya { dimension "platform" applicationId "com.develop.foodcooking" buildConfigField("String", "UpdatePlatform", "\"normal\"") resValue("string", "app_theme", "@style/SplashTheme") buildConfigField("String", "model", "\"3015\"") buildConfigField("String", "brandCode", "\"012A\"") } } signingConfigs { debug { storeFile file('..\\signature\\rk.jks') storePassword '123456' keyAlias 'rk' keyPassword '123456' } foodCooking { storeFile file("..\\signature\\rk.jks") storePassword '123456' keyAlias 'rk' keyPassword '123456' } release { storeFile file('..\\signature\\rk.jks') storePassword '123456' keyAlias 'rk' keyPassword '123456' } } //自定义输出包名的设置 applicationVariants.all { variant -> variant.outputs.all { // 输出apk名称为sharev1.0_tencent.apk def fileName = "cofar-cooking_${defaultConfig.versionName}_${variant.productFlavors[0].name}_release.apk" outputFileName = fileName } } buildTypes { release { debuggable true minifyEnabled false productFlavors.brand034.signingConfig signingConfigs.release productFlavors.brand000ATuya.signingConfig signingConfigs.release productFlavors.brand012ATuya.signingConfig signingConfigs.release productFlavors.brandDefault.signingConfig signingConfigs.release proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } debug{ debuggable true // buildConfigField("String", "UpdatePlatform", "\"night\"") // resValue("string", "app_theme", "@style/Splash034Theme") // buildConfigField("String", "model", "\"3015\"") // buildConfigField("String", "brandCode", "\"034A\"") // // manifestPlaceholders = [channelName: "brand000ATuya"] // buildConfigField("String", "UpdatePlatform", "\"normal\"") // resValue("string", "app_theme", "@style/SplashTheme") // buildConfigField("String", "model", "\"3015\"") // buildConfigField("String", "brandCode", "\"000A\"") manifestPlaceholders = [channelName: "brand034"] buildConfigField("String", "UpdatePlatform", "\"night\"") resValue("string", "app_theme", "@style/Splash034Theme") buildConfigField("String", "model", "\"3015\"") buildConfigField("String", "brandCode", "\"034A\"") // manifestPlaceholders = [channelName: "brand058A"] // buildConfigField("String", "UpdatePlatform", "\"normal\"") // resValue("string", "app_theme", "@style/SplashTheme") // buildConfigField("String", "model", "\"3015\"") // buildConfigField("String", "brandCode", "\"058A\"") } //输出类型 applicationVariants.all { //判断是release还是debug版本 def buildType = it.buildType.name //获取当前时间的"YYYY-MM-dd"格式。 def createTime = new Date().format("YYYY-MM-dd-HHmm", TimeZone.getTimeZone("GMT+08:00")) //如果是正式包,将其输入到指定文件夹 if (buildType == "release") { it.getPackageApplication().outputDirectory = new File('D:\\out_apk_food/'+ "${it.productFlavors[0].name}/${createTime}") } } } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } kotlinOptions { jvmTarget = '1.8' } viewBinding { enabled = true } } dependencies { implementation project(path: ':libBase') implementation project(path: ':BusinessRouter') implementation project(path: ':BusinessAuth') implementation project(path: ':BusinessSetting') implementation project(path: ':BusinessMain') implementation project(path: ':BusinessStep') kapt 'com.alibaba:arouter-compiler:1.5.1' }