我的問題似乎與我如何實現build.gradle。我固定它,這是它應該如何看,當你希望有不同的密鑰庫針對每種口味,如:
signingConfigs {
println 'Sign apk config'
falvor1 {
/** Details for signing the application */
def props = new Properties()
props.load(new FileInputStream(rootProject.file("release.properties.flavor1")))
storeFile file(rootProject.file(props.keyStore))
storePassword props.keyStorePassword
keyAlias props.keyAlias
keyPassword props.keyAliasPassword
}
flavor2 {
/** Details for signing the application */
def props = new Properties()
props.load(new FileInputStream(rootProject.file("release.properties.flavor2")))
storeFile file(rootProject.file(props.keyStore))
storePassword props.keyStorePassword
keyAlias props.keyAlias
keyPassword props.keyAliasPassword
}
}
/** Add product flavours for all variants of application */
productFlavors {
flavor1 {
// Update the application ID/ Package name
applicationId "com.my.application.flavor1"
/* Update the version code & version name */
versionCode 100
versionName "1.0.0.1"
}
flavor2 {
// Update the application ID/ Package name
applicationId "com.my.application.flavor2"
/* Update the version code & version name */
versionCode 200
versionName "2.0.0.2"
}
}
buildTypes {
debug {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
zipAlign true
}
release {
//Only use the release key on a release buildType
productFlavors.flavor1.signingConfig signingConfigs.flavor1
productFlavors.flavor2.signingConfig signingConfigs.flavor2
runProguard true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
zipAlign true
}
}
release.properties.flavor結構
// Name of the keystore file
keyStore=flavor1.keystore
// keystore password
keyStorePassword=flavor1pass
// Key alias
keyAlias=flavor1_alias
// Key password
keyAliasPassword=flavor1pass
您可能會發現一些在有效關於確定簽名者,驗證證書等方面的現有問題。 – 2014-10-30 08:05:13
運行「jarsigner -verify -verbose -certs my.apk」命令告訴我,來自Gradle的apk簽名過程被搞砸了。它總是隻採用最新的密鑰庫文件。 我會發布我的更新build.gradle文件,它適用於每種口味的不同密鑰庫。 – 2014-10-30 08:59:41