Home > Blockchain >  How to sign Multiple Flavor APK's with a Single Keystore
How to sign Multiple Flavor APK's with a Single Keystore

Time:05-15

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 ?

CodePudding user response:

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
    }

CodePudding user response:

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")
        }

    }
  • Related