How to sign Multiple Flavor APK's with a Single Keystore
Asked Answered
R

2

1

I have 11 flavors for an app and one Keystore for an app. I hoped to use one keystore to sign multiple product flavors like below.

signingConfigs {
    release {
        storeFile file("Users/avalon/retailr.jks")
        storePassword storePassword
        keyAlias "alias"
        keyPassword keyPassword
    }
}
...
...
productFlavors{
    flavorone {
        ...
        signingConfig signingConfigs.release
    }
    flavortwo {
        ...
        signingConfig signingConfigs.release
    }



}

However i keep getting an error during running a Configuration that The apk for your currently selected variant cannot be signed. Please specify a signing configuration for this variant (flavorone-release). Does that mean I have to make 11 different keystore configurations for the apps or is there a way i can use one ?

Rennin answered 14/5, 2022 at 12:35 Comment(1)
Sounds more like a bug. Do you have enabled parallel execution of gradle? If yes this could be a concurrency problem (all flavors run signing at the same time).Karee
A
1

Have you tried like this ?

  signingConfigs {
    configFlavor1 {
        keyAlias 'abcdef'
        keyPassword 'password'
        storeFile file('keystore.jks')
        storePassword 'password'
    }

    configFlavor2 {
        keyAlias 'abcdef'
        keyPassword 'password'
        storeFile file('keystore.jks')
        storePassword 'password'
    }

}

Then in

  buildTypes {
    release {
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        productFlavors.flavor1.signingConfig signingConfigs.configFlavor1
       

        productFlavors.flavor2.signingConfig signingConfigs.configFlavor2
    }
Aquiculture answered 14/5, 2022 at 13:31 Comment(2)
That actually works thanks. Are there any problems/violations arising from signing the app with the same key once you upload the apps to Playstore ?Rennin
Where is the part that "connects" here between the package-name and the key-configuration to sign with ("configFlavor1", "configFlavor2") ?Westbound
M
0

You don't have to add multiple configs for each variant. In the app/build.gradle you can mention in the build types like following

buildTypes {
    release {
        signingConfig signingConfigs.release
    }
}

and in your signinconfig section you can have like following

signingConfigs {
        release {
            keyAlias 'keyAlias'
            keyPassword 'keyPassword'
            storePassword 'storePassword'
            storeFile file("${rootDir}/keystores/app.keystore")
        }

    }
Marras answered 14/5, 2022 at 13:23 Comment(1)
I have done this. Release has a signing config. But still get the error above.Rennin

© 2022 - 2024 — McMap. All rights reserved.