嘗試使用applicationIdSuffix
像改變每個產品風味的應用程序ID:
android {
...
defaultConfig {
applicationId "mx.com.locker"
...
}
productFlavors {
starwing {
applicationIdSuffix ".starwing"
versionCode 11
versionName "1.11"
}
puntoarq {
applicationIdSuffix ".puntoarq"
versionCode 1
versionName "1"
}
}
}
並確保您有針對每種口味的res文件夾在各自的目錄是這樣的:
# common/default resources here
app/src/main/res/values
\___ /styles.xml
|___ /colors.xml
\__ ...
# starwing resources here
app/src/starwing/res/values
\___ /styles.xml
|___ /colors.xml
\__ ...
# puntoarq resources here
app/src/puntoarq/res/values
\___ /styles.xml
|___ /colors.xml
\__ ...
如果您使用的是某些Google服務,則源代碼文件和google-services.json
也是如此。
# common/default resources here
app/src/main/google-services.json
# starwing resources here
app/src/starwing/google-services.json
# puntoarq resources here
app/src/puntoarq/google-services.json
你可以建立特定的香味從選擇的Android Studio中構建變量或運行./gradlew assembleStarwingRelease
或./gradlew assemblePuntoarqRelease
。
你可以看看here瞭解更多信息。