I am trying to generate a signed APK for my app and it works if I only use signature V1. When I use signature V2 and then check apk with keytool, the output is:
keytool -list -printcert -jarfile app-release.apk
Not a signed jar file
Here is the build.gradle:
def getProps(path) {
Properties props = new Properties()
props.load(project.rootProject.file(path).newDataInputStream())
return props
}
android {
...
signingConfigs {
debug {
try {
Properties props = getProps('./local.properties')
storeFile file(props.getProperty('DEBUG_STORE_FILE', ''))
keyAlias props.getProperty('DEBUG_KEY_ALIAS', '')
keyPassword props.getProperty('DEBUG_STORE_PASSWORD', '')
storePassword props.getProperty('DEBUG_STORE_PASSWORD', '')
v1SigningEnabled true
v2SigningEnabled false // enabling this generates unsigned apk
}
catch (ex) {
throw new InvalidUserDataException("You should define RELEASE_STORE_FILE, RELEASE_KEY_ALIAS, RELEASE_STORE_PASSWORD in local.properties.")
}
}
release {
try {
Properties props = getProps('./local.properties')
storeFile file(props.getProperty('RELEASE_STORE_FILE', ''))
keyAlias props.getProperty('RELEASE_KEY_ALIAS', '')
keyPassword props.getProperty('RELEASE_STORE_PASSWORD', '')
storePassword props.getProperty('RELEASE_STORE_PASSWORD', '')
v1SigningEnabled true
v2SigningEnabled false // enabling this generates unsigned apk
}
catch (ex) {
throw new InvalidUserDataException("You should define RELEASE_STORE_FILE, RELEASE_KEY_ALIAS, RELEASE_STORE_PASSWORD in local.properties.")
}
}
}
defaultConfig {
...
// Only productionRelease flavour uses signingConfigs.release;
// other flavours(i.e. productionDebug, developmentDebug, developmentRelease)
// use signingConfigs.debug
// https://mcmap.net/q/66399/-gradle-signing-flavors-with-different-keys-on-android
signingConfig signingConfigs.release
}
buildTypes {
release {
...
}
debug {
...
signingConfig signingConfigs.debug
}
}
// Dimensions: environment can be one of [development, production]
flavorDimensions "environment"
productFlavors {
development {
...
signingConfig signingConfigs.debug
...
}
production {
dimension "environment"
}
}
...
}
I also created a new Android project from scratch and it has the same issue.
Note that I have another Android project which can produce a signed APK selecting both V1 and V2.
Why adding signature V2 is causing the generation of an unsigned APK?