打包設置
flavorDimensions("channel")
productFlavors {
demo {
manifestPlaceholders = [APP_NAME: "@string/app_name_demo"]
applicationId "com.example.demo"
buildConfigField 'String', 'SERVICE_ITEM', "\"0\""
dimension "channel"
}
release{
manifestPlaceholders = [APP_NAME: "@string/app_name"]
applicationId "com.example.release"
buildConfigField 'String', 'SERVICE_ITEM', "\"1\""
dimension "channel"
}
}
//自定義apk文件名
applicationVariants.all { variant ->
variant.outputs.all { output ->
def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith('.apk')) {
// def npstr = android.buildTypes.release.minifyEnabled ? "" : "_np"
def flavor = variant.productFlavors[0]
def typeName
switch (flavor.name) {
case "demo":
typeName = "測試版"
break
case "release":
typeName = "正式版"
break
default:
break
}
outputFileName = "DEMO${releaseTime()}_v${flavor.versionName}_${typeName}.apk"
}
}
}
buildTypes {
debug {
// applicationIdSuffix ".debug"
manifestPlaceholders = [APP_NAME: "@string/app_name_debug"]
}
release {
manifestPlaceholders = [APP_NAME: "@string/app_name"]
// 是否進行混淆
minifyEnabled false
// 混淆配置文件
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
}
}
Android Studio打包設置分支
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.