我在同一个Android Studio项目中有两个不同的应用程序。我有两种口味&1;味道1'和' flavor2'有三种不同的构建类型' staging',' debug'并且'发布'
问题是我需要为每个应用程序使用不同的密钥库。
现在我有了这个,但它只与相同的密钥库签名。
signingConfigs {
release {
def Properties props = new Properties()
def propFile = new File('./signing.properties')
if (propFile.canRead()) {
props.load(new FileInputStream(propFile))
if (props != null && props.containsKey('STORE_FILE')
&& props.containsKey('STORE_PASSWORD')
&& props.containsKey('KEY_ALIAS')
&& props.containsKey('KEY_PASSWORD')) {
android.signingConfigs.release.storeFile = file(props.getProperty('STORE_FILE'))
android.signingConfigs.release.storePassword = props.getProperty('STORE_PASSWORD')
android.signingConfigs.release.keyAlias = props.getProperty('KEY_ALIAS')
android.signingConfigs.release.keyPassword = props.getProperty('KEY_PASSWORD')
} else {
println 'signing.properties found but some entries are missing'
android.buildTypes.release.signingConfig = null
}
} else {
println 'signing.properties not found'
android.buildTypes.release.signingConfig = null
}
}
}
buildTypes {
staging {
debuggable true
signingConfig android.signingConfigs.debug
}
debug {
debuggable true
signingConfig android.signingConfigs.debug
}
release {
debuggable false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
signingConfig signingConfigs.release
minifyEnabled false
}
}
答案 0 :(得分:0)
您可以创建特定于风味的签名配置:
一个例子:
signingConfigs {
flavor1Release {
storeFile file('home/keys/flavor1keystore.keystore')
storePassword 'keystorePassword'
keyAlias 'alias'
keyPassword 'aliasPassword'
}
flavor2Release {
storeFile file('home/keys/flavor2keystore.keystore')
storePassword 'keystorePassword2'
keyAlias 'alias2'
keyPassword 'aliasPassword2'
}
}
然后在您的风格中,选择正确的签名配置:
productFlavors {
def flavor1SigningVariable = signingConfigs.flavor1Release
def flavor2SigningVariable = signingConfigs.flavor2Release
flavor1 {
signingConfig flavor1SigningVariable
}
flavor2 {
signingConfig flavor2SigningVariable
}
}