我的build.gradle文件中指定了不同的productFlavor
require
并拥有像
这样的签名配置 dev {
applicationId "com.advancedprogressive.chare.dev"
versionCode 83
versionName "2.2.1"
}
staging {
applicationId "com.advancedprogressive.chare.qa"
versionCode 119
versionName "2.8.1"
}
我有两种口味的不同keystors。我可以为不同的构建类型指定不同的密钥库,例如debug / release,但是我如何为每种风格指定不同的keysotre。
答案 0 :(得分:3)
使用以下gradle
,您可以实现多个productFlavors:
android {
signingConfigs {
release {
keyAlias 'alias'
keyPassword 'password'
storeFile file('first.keystore')
storePassword 'password'
}
debug {
keyAlias 'alias'
keyPassword 'password'
storeFile file('second.keystore')
storePassword 'password'
}
}
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
minSdkVersion 14
targetSdkVersion 23
}
productFlavors{
dev {
applicationId "com.advancedprogressive.chare.dev"
versionCode 83
versionName "2.2.1"
signingConfig signingConfigs.debug
}
staging {
applicationId "com.advancedprogressive.chare.qa"
versionCode 119
versionName "2.8.1"
signingConfig signingConfigs.release
}
}
}
我希望它对你有所帮助。
答案 1 :(得分:3)
你可以像这样使用somenthing:
android {
signingConfigs {
dev {
}
staging {
}
}
productFlavors {
dev {
signingConfig signingConfigs.dev
}
staging {
signingConfig signingConfigs.staging
}
}
}
答案 2 :(得分:0)
在互联网上搜索后,我在任何地方都找不到清晰的示例。我尝试了一下,终于成功了!
android{
signingConfigs {
free {
def keystorePropertiesFile = rootProject.file("app/src/free/keystore.properties")
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
}
paid {
def keystorePropertiesFile = rootProject.file("app/src/paid/keystore.properties")
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
}
}
...
flavorDimensions "default"
productFlavors {
free {
applicationId "com.example.freeapp"
versionCode 1
versionName "1.0"
signingConfig signingConfigs.free
}
paid {
applicationId 'com.example.paidapp'
versionCode 1
versionName '1.0'
signingConfig signingConfigs.paid
}
}
}
storePassword=...
keyPassword=..
keyAlias=...
storeFile=src/flavor_name/keystore_file.jks //or any other path of jks file