Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Different keyStore for different product flavors in Gradle

I have different productFlavors specified in my build.gradle file

 dev {
            applicationId "com.advancedprogressive.chare.dev"
            versionCode 83
            versionName "2.2.1"
        }
staging {
            applicationId "com.advancedprogressive.chare.qa"
            versionCode 119
            versionName "2.8.1"
        }

and have have signing configurations like

signingConfigs {
        release {
            storeFile 
            storePassword 
            keyAlias 
            keyPassword         }
        debug {
            keyPassword 
            storeFile 
            keyAlias 
            storePassword 
        }
    }

I have different keystors for both flavors. I can specify different keystores for different build types e.g debug/release but how can i specify different keysotre for each flavor.

like image 722
SAIR Avatar asked Mar 24 '16 07:03

SAIR


2 Answers

Using below gradle you can achieve multiple productFlavors :

   android {
  signingConfigs {
    release {
        keyAlias 'alias'
        keyPassword 'password'
        storeFile file('first.keystore')
        storePassword 'password'
    }

    debug {
        keyAlias 'alias'
        keyPassword 'password'
        storeFile file('second.keystore')
        storePassword 'password'
    }
  }

  compileSdkVersion 23
  buildToolsVersion "23.0.2"
  defaultConfig {
        minSdkVersion 14
        targetSdkVersion 23
     }

      productFlavors{
        dev {
            applicationId "com.advancedprogressive.chare.dev"
            versionCode 83
            versionName "2.2.1"
            signingConfig signingConfigs.debug 
        }
        staging {
            applicationId "com.advancedprogressive.chare.qa"
            versionCode 119
            versionName "2.8.1"
            signingConfig signingConfigs.release
        }
  }

      }

I hope its help you.

like image 121
pRaNaY Avatar answered Oct 24 '22 15:10

pRaNaY


You can use somenthing like this:

android {
    signingConfigs {
        dev {
        }

        staging {
        }
    }

    productFlavors {
        dev {
            signingConfig signingConfigs.dev
        }

        staging {
            signingConfig signingConfigs.staging
        } 
    }
}
like image 26
Gabriele Mariotti Avatar answered Oct 24 '22 13:10

Gabriele Mariotti