我有六个版本,比如
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.config
manifestPlaceholders = [appVersion: ""];
}
staging {
applicationIdSuffix '.staging'
versionNameSuffix '-staging'
manifestPlaceholders = [appVersion: "-stg"];
}
debug {
applicationIdSuffix '.debug'
versionNameSuffix '-debug'
manifestPlaceholders = [appVersion: "-debug"];
}
}
productFlavors {
panel {
versionCode 2
versionName '1.1'
applicationIdSuffix '.panel'
manifestPlaceholders = [appName: "exampleapp-panel"];
}
admin {
manifestPlaceholders = [appName: "exampleapp-admin"];
}
}
我想为每个版本更改每个函数或变量 我可以在XCode中使用它this way,但我还没有在Android studio中找到方法。
我可以在AndroidStudio中使用这样的设置文件吗?
答案 0 :(得分:0)
对于每种构建/产品风格,您可以使用以下内容。
buildConfigField "boolean", "VALUE_KEY", "true"
resValue "string", "my_string", "Some string"
第一个可以在你的代码中访问BuildConfig.VALUE_KEY,第二个被写入strings.xml
答案 1 :(得分:0)
试试这个:
productFlavors {
pro {
minSdkVersion 15
applicationId 'com.myapps'
signingConfig signingConfigs.release
targetSdkVersion 23
resValue "string", "app_name", "myapps"
buildConfigField "boolean", "IS_DEV", "false"
}
dev {
minSdkVersion 15
applicationId 'com.myapps.dev'
targetSdkVersion 23
resValue "string", "app_name", "myapps 1.2"
buildConfigField "boolean", "IS_DEV", "true"
}
}