我需要为许多品牌构建应用程序。如何在defaultConfig中更改applicationId?
compileSdkVersion 19
buildToolsVersion '25.0.0'
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
}
defaultConfig {
multiDexEnabled false
applicationId = ""
minSdkVersion 14
targetSdkVersion 19
signingConfig signingConfigs.config
}
和Gradle脚本一样,但它不能正常工作
task buildForBrand {
applicationId = "abc.${newBrand}"
}
答案 0 :(得分:0)
您可以简单地使用Build Variants。它会覆盖你的defaultConfig&你还可以添加更多变量,如base_url等。对于Ex:
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.yourApp.pkg"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
buildFlavor1 {
applicationId "com.yourApp.pkg1"
}
buildFlavor2 {
applicationId "com.yourApp.pkg2"
}
}
}
有关详细信息,请转到link。