Multiple signing configs in a project e.g. (free/paid)Gradle, 'could not find property'Kotlin fails to compile a libraryGradle build: Could not find method signingConfig() for argumentsAndroid Studio 3.2.1 - New project fails to runAndroid - Kotlin files are present in apk after compilationAll flavors must now belong to a named flavor dimension Android Studio NDKdebug-apk work fine but sign apk release crash on main acitvityCould not find class 'dalvik.system…'

How invisible hand adjusts stock prices if company is listed on multiple exchanges, under multiple currencies, and one of the currencies plunges?

Why is Sojdlg123aljg a common password?

antimatter annihilation in stars

Bit floating sequence

Galilean transformation vs simple translation

How to finish my PhD?

Capacitors with same voltage, same capacitance, same temp, different diameter?

What's the biggest difference between these two photos?

The meaning of "offing" in "an agreement in the offing"

How to run NPCs with complicated mechanics?

How do English-speaking kids loudly request something?

Why does 8 bit truecolor use only 2 bits for blue?

How strong is aircraft-grade spruce?

Complex conjugate and transpose "with respect to a basis"

Automatically end list item with proper punctuation (semicolon, period)

Explaining "向けてじゃないよ"

Features seen on the Space Shuttle's solid booster; what does "LOADED" mean exactly?

Why does PAUSE key have a long make code and no break code?

I multiply the source, you (probably) multiply the output!

I need to know information from an old German birth certificate

Is future tense in English really a myth?

Force to install a software on older macos version

Contractor cut joist hangers to make them fit

Problem with listing a directory to grep



Multiple signing configs in a project e.g. (free/paid)


Gradle, 'could not find property'Kotlin fails to compile a libraryGradle build: Could not find method signingConfig() for argumentsAndroid Studio 3.2.1 - New project fails to runAndroid - Kotlin files are present in apk after compilationAll flavors must now belong to a named flavor dimension Android Studio NDKdebug-apk work fine but sign apk release crash on main acitvityCould not find class 'dalvik.system…'






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I have configured my app build.gradle with free and paid version with different keystores. look at the code below.



apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'

android
signingConfigs
freeProdRelease
keyAlias 'free.prod.release.key'
keyPassword 'password'
storeFile file('F:/freeProdRelease.jks')
storePassword 'password'

paidProdRelease
keyAlias 'paid.prod.release.key'
keyPassword 'password'
storeFile file('F:/paidProdRelease.jks')
storePassword 'password'


compileSdkVersion 28
defaultConfig
applicationId "com.example.the.app"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
buildConfigField "long", "BUILD_DATE", "$System.currentTimeMillis()L"

buildTypes
release
resValue "string", "some_api_key", "key for release"
shrinkResources true //remove unused resources... will reduce APK size
debuggable false
useProguard true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

debug
resValue "string", "some_api_key", "key for debug"
debuggable true
useProguard false
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'


flavorDimensions "version", "environment"
productFlavors
free
dimension "version"
buildConfigField 'boolean', 'IS_PAID', 'false'
versionNameSuffix "-free"
applicationIdSuffix ".free"

paid
dimension "version"
buildConfigField 'boolean', 'IS_PAID', 'true'
versionNameSuffix "-paid"
applicationIdSuffix ".paid"

dev
dimension "environment"
versionCode 2000 + android.defaultConfig.versionCode
versionNameSuffix "-dev"
applicationIdSuffix ".dev"
manifestPlaceholders = [appLabel: "The App - Dev"]

prod
dimension "environment"
versionCode android.defaultConfig.versionCode
manifestPlaceholders = [appLabel: "The App"]


applicationVariants.all variant ->
if(variant.buildType.name == "release")
if(variant.productFlavors[0].name == "paid")
android.buildTypes.release.signingConfig android.signingConfigs.paidProdRelease
else
android.buildTypes.release.signingConfig android.signingConfigs.freeProdRelease


variant.outputs.each output ->
def apkName = "theApp-v" + android.defaultConfig.versionName + "-c" +
variant.productFlavors[1].versionCode

apkName +=
"-$variant.productFlavors[0].name-" +
"$variant.productFlavors[1].name-$variant.buildType.name-$releaseTime()"
apkName += ".apk"

output.outputFileName = new File("$apkName")


dexOptions
javaMaxHeapSize "4g"

configurations.all
resolutionStrategy.eachDependency DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == 'com.android.support')
if (!requested.name.startsWith("multidex"))
details.useVersion '27.1.1'




testOptions
unitTests.returnDefaultValues = true



static def releaseTime()
return new Date().format("yyyy-MMM-dd")


dependencies
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "com.android.support.constraint:constraint-layout:$constraintLayoutVersion"
implementation "com.android.support:appcompat-v7:$supportLibraryVersion"
implementation "com.android.support:recyclerview-v7:$supportLibraryVersion"
implementation "com.android.support:design:$supportLibraryVersion"
implementation "com.android.support:support-v4:$supportLibraryVersion"
implementation "android.arch.persistence.room:runtime:$roomVersion"
kapt "android.arch.persistence.room:compiler:$roomVersion"
implementation "android.arch.lifecycle:extensions:$archLifecycleVersion"
kapt "android.arch.lifecycle:compiler:$archLifecycleVersion"

//dagger 2

// implementation "com.google.dagger:dagger:$daggerVersion"

// kapt "com.google.dagger:dagger-compiler:$daggerVersion"

//to enable DaggerActivity, DaggerBroadcastReceiver, DaggerFragment etc classes

// implementation "com.google.dagger:dagger-android:$daggerVersion"

// kapt "com.google.dagger:dagger-android-processor:$daggerVersion"

//support libraries with dagger 2

// implementation "com.google.dagger:dagger-android-support:$daggerVersion"
// implementation "com.google.code.gson:gson:$gsonVersion"
// implementation "pub.devrel:easypermissions:$easyPermissionVersion"
// implementation "com.github.ybq:Android-SpinKit:$spinKitVersion"

//progress view
// implementation "com.squareup.retrofit2:retrofit:$retrofitVersion"
// implementation "com.squareup.retrofit2:converter-gson:$retrofitVersion"

// implementation "org.greenrobot:eventbus:$eventBusVersion"
// implementation "com.github.bumptech.glide:glide:$glideVersion"
// kapt "com.github.bumptech.glide:compiler:$glideVersion"
// implementation "com.joooonho:selectableroundedimageview:$selectableRoundedImageViewVersion"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'



What I want is when I change my variant freeProdRelease or paidProdRelease and create release build then keystore file should be selected according to variant. for that I have setup code below



if(variant.buildType.name == "release") 
if(variant.productFlavors[0].name == "paid")
android.buildTypes.release.signingConfig android.signingConfigs.paidProdRelease
else
android.buildTypes.release.signingConfig android.signingConfigs.freeProdRelease




When I remove the above code then It gives error for release build and that is fine.



But when I commented else block and creating release build it still works and doesn't give error for keystore file, It means each time keystore file will be used paidProdRelease that I don't want.



if(variant.buildType.name == "release") 
if(variant.productFlavors[0].name == "paid")
android.buildTypes.release.signingConfig android.signingConfigs.paidProdRelease
else
// android.buildTypes.release.signingConfig android.signingConfigs.freeProdRelease




What should I do to use different keystore file for respected version free/paid?










share|improve this question
































    0















    I have configured my app build.gradle with free and paid version with different keystores. look at the code below.



    apply plugin: 'com.android.application'
    apply plugin: 'kotlin-android'
    apply plugin: 'kotlin-android-extensions'
    apply plugin: 'kotlin-kapt'

    android
    signingConfigs
    freeProdRelease
    keyAlias 'free.prod.release.key'
    keyPassword 'password'
    storeFile file('F:/freeProdRelease.jks')
    storePassword 'password'

    paidProdRelease
    keyAlias 'paid.prod.release.key'
    keyPassword 'password'
    storeFile file('F:/paidProdRelease.jks')
    storePassword 'password'


    compileSdkVersion 28
    defaultConfig
    applicationId "com.example.the.app"
    minSdkVersion 21
    targetSdkVersion 28
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    buildConfigField "long", "BUILD_DATE", "$System.currentTimeMillis()L"

    buildTypes
    release
    resValue "string", "some_api_key", "key for release"
    shrinkResources true //remove unused resources... will reduce APK size
    debuggable false
    useProguard true
    minifyEnabled true
    proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

    debug
    resValue "string", "some_api_key", "key for debug"
    debuggable true
    useProguard false
    minifyEnabled false
    proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'


    flavorDimensions "version", "environment"
    productFlavors
    free
    dimension "version"
    buildConfigField 'boolean', 'IS_PAID', 'false'
    versionNameSuffix "-free"
    applicationIdSuffix ".free"

    paid
    dimension "version"
    buildConfigField 'boolean', 'IS_PAID', 'true'
    versionNameSuffix "-paid"
    applicationIdSuffix ".paid"

    dev
    dimension "environment"
    versionCode 2000 + android.defaultConfig.versionCode
    versionNameSuffix "-dev"
    applicationIdSuffix ".dev"
    manifestPlaceholders = [appLabel: "The App - Dev"]

    prod
    dimension "environment"
    versionCode android.defaultConfig.versionCode
    manifestPlaceholders = [appLabel: "The App"]


    applicationVariants.all variant ->
    if(variant.buildType.name == "release")
    if(variant.productFlavors[0].name == "paid")
    android.buildTypes.release.signingConfig android.signingConfigs.paidProdRelease
    else
    android.buildTypes.release.signingConfig android.signingConfigs.freeProdRelease


    variant.outputs.each output ->
    def apkName = "theApp-v" + android.defaultConfig.versionName + "-c" +
    variant.productFlavors[1].versionCode

    apkName +=
    "-$variant.productFlavors[0].name-" +
    "$variant.productFlavors[1].name-$variant.buildType.name-$releaseTime()"
    apkName += ".apk"

    output.outputFileName = new File("$apkName")


    dexOptions
    javaMaxHeapSize "4g"

    configurations.all
    resolutionStrategy.eachDependency DependencyResolveDetails details ->
    def requested = details.requested
    if (requested.group == 'com.android.support')
    if (!requested.name.startsWith("multidex"))
    details.useVersion '27.1.1'




    testOptions
    unitTests.returnDefaultValues = true



    static def releaseTime()
    return new Date().format("yyyy-MMM-dd")


    dependencies
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation "com.android.support.constraint:constraint-layout:$constraintLayoutVersion"
    implementation "com.android.support:appcompat-v7:$supportLibraryVersion"
    implementation "com.android.support:recyclerview-v7:$supportLibraryVersion"
    implementation "com.android.support:design:$supportLibraryVersion"
    implementation "com.android.support:support-v4:$supportLibraryVersion"
    implementation "android.arch.persistence.room:runtime:$roomVersion"
    kapt "android.arch.persistence.room:compiler:$roomVersion"
    implementation "android.arch.lifecycle:extensions:$archLifecycleVersion"
    kapt "android.arch.lifecycle:compiler:$archLifecycleVersion"

    //dagger 2

    // implementation "com.google.dagger:dagger:$daggerVersion"

    // kapt "com.google.dagger:dagger-compiler:$daggerVersion"

    //to enable DaggerActivity, DaggerBroadcastReceiver, DaggerFragment etc classes

    // implementation "com.google.dagger:dagger-android:$daggerVersion"

    // kapt "com.google.dagger:dagger-android-processor:$daggerVersion"

    //support libraries with dagger 2

    // implementation "com.google.dagger:dagger-android-support:$daggerVersion"
    // implementation "com.google.code.gson:gson:$gsonVersion"
    // implementation "pub.devrel:easypermissions:$easyPermissionVersion"
    // implementation "com.github.ybq:Android-SpinKit:$spinKitVersion"

    //progress view
    // implementation "com.squareup.retrofit2:retrofit:$retrofitVersion"
    // implementation "com.squareup.retrofit2:converter-gson:$retrofitVersion"

    // implementation "org.greenrobot:eventbus:$eventBusVersion"
    // implementation "com.github.bumptech.glide:glide:$glideVersion"
    // kapt "com.github.bumptech.glide:compiler:$glideVersion"
    // implementation "com.joooonho:selectableroundedimageview:$selectableRoundedImageViewVersion"
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'



    What I want is when I change my variant freeProdRelease or paidProdRelease and create release build then keystore file should be selected according to variant. for that I have setup code below



    if(variant.buildType.name == "release") 
    if(variant.productFlavors[0].name == "paid")
    android.buildTypes.release.signingConfig android.signingConfigs.paidProdRelease
    else
    android.buildTypes.release.signingConfig android.signingConfigs.freeProdRelease




    When I remove the above code then It gives error for release build and that is fine.



    But when I commented else block and creating release build it still works and doesn't give error for keystore file, It means each time keystore file will be used paidProdRelease that I don't want.



    if(variant.buildType.name == "release") 
    if(variant.productFlavors[0].name == "paid")
    android.buildTypes.release.signingConfig android.signingConfigs.paidProdRelease
    else
    // android.buildTypes.release.signingConfig android.signingConfigs.freeProdRelease




    What should I do to use different keystore file for respected version free/paid?










    share|improve this question




























      0












      0








      0








      I have configured my app build.gradle with free and paid version with different keystores. look at the code below.



      apply plugin: 'com.android.application'
      apply plugin: 'kotlin-android'
      apply plugin: 'kotlin-android-extensions'
      apply plugin: 'kotlin-kapt'

      android
      signingConfigs
      freeProdRelease
      keyAlias 'free.prod.release.key'
      keyPassword 'password'
      storeFile file('F:/freeProdRelease.jks')
      storePassword 'password'

      paidProdRelease
      keyAlias 'paid.prod.release.key'
      keyPassword 'password'
      storeFile file('F:/paidProdRelease.jks')
      storePassword 'password'


      compileSdkVersion 28
      defaultConfig
      applicationId "com.example.the.app"
      minSdkVersion 21
      targetSdkVersion 28
      versionCode 1
      versionName "1.0"
      testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
      buildConfigField "long", "BUILD_DATE", "$System.currentTimeMillis()L"

      buildTypes
      release
      resValue "string", "some_api_key", "key for release"
      shrinkResources true //remove unused resources... will reduce APK size
      debuggable false
      useProguard true
      minifyEnabled true
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

      debug
      resValue "string", "some_api_key", "key for debug"
      debuggable true
      useProguard false
      minifyEnabled false
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'


      flavorDimensions "version", "environment"
      productFlavors
      free
      dimension "version"
      buildConfigField 'boolean', 'IS_PAID', 'false'
      versionNameSuffix "-free"
      applicationIdSuffix ".free"

      paid
      dimension "version"
      buildConfigField 'boolean', 'IS_PAID', 'true'
      versionNameSuffix "-paid"
      applicationIdSuffix ".paid"

      dev
      dimension "environment"
      versionCode 2000 + android.defaultConfig.versionCode
      versionNameSuffix "-dev"
      applicationIdSuffix ".dev"
      manifestPlaceholders = [appLabel: "The App - Dev"]

      prod
      dimension "environment"
      versionCode android.defaultConfig.versionCode
      manifestPlaceholders = [appLabel: "The App"]


      applicationVariants.all variant ->
      if(variant.buildType.name == "release")
      if(variant.productFlavors[0].name == "paid")
      android.buildTypes.release.signingConfig android.signingConfigs.paidProdRelease
      else
      android.buildTypes.release.signingConfig android.signingConfigs.freeProdRelease


      variant.outputs.each output ->
      def apkName = "theApp-v" + android.defaultConfig.versionName + "-c" +
      variant.productFlavors[1].versionCode

      apkName +=
      "-$variant.productFlavors[0].name-" +
      "$variant.productFlavors[1].name-$variant.buildType.name-$releaseTime()"
      apkName += ".apk"

      output.outputFileName = new File("$apkName")


      dexOptions
      javaMaxHeapSize "4g"

      configurations.all
      resolutionStrategy.eachDependency DependencyResolveDetails details ->
      def requested = details.requested
      if (requested.group == 'com.android.support')
      if (!requested.name.startsWith("multidex"))
      details.useVersion '27.1.1'




      testOptions
      unitTests.returnDefaultValues = true



      static def releaseTime()
      return new Date().format("yyyy-MMM-dd")


      dependencies
      implementation fileTree(include: ['*.jar'], dir: 'libs')
      implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
      implementation "com.android.support.constraint:constraint-layout:$constraintLayoutVersion"
      implementation "com.android.support:appcompat-v7:$supportLibraryVersion"
      implementation "com.android.support:recyclerview-v7:$supportLibraryVersion"
      implementation "com.android.support:design:$supportLibraryVersion"
      implementation "com.android.support:support-v4:$supportLibraryVersion"
      implementation "android.arch.persistence.room:runtime:$roomVersion"
      kapt "android.arch.persistence.room:compiler:$roomVersion"
      implementation "android.arch.lifecycle:extensions:$archLifecycleVersion"
      kapt "android.arch.lifecycle:compiler:$archLifecycleVersion"

      //dagger 2

      // implementation "com.google.dagger:dagger:$daggerVersion"

      // kapt "com.google.dagger:dagger-compiler:$daggerVersion"

      //to enable DaggerActivity, DaggerBroadcastReceiver, DaggerFragment etc classes

      // implementation "com.google.dagger:dagger-android:$daggerVersion"

      // kapt "com.google.dagger:dagger-android-processor:$daggerVersion"

      //support libraries with dagger 2

      // implementation "com.google.dagger:dagger-android-support:$daggerVersion"
      // implementation "com.google.code.gson:gson:$gsonVersion"
      // implementation "pub.devrel:easypermissions:$easyPermissionVersion"
      // implementation "com.github.ybq:Android-SpinKit:$spinKitVersion"

      //progress view
      // implementation "com.squareup.retrofit2:retrofit:$retrofitVersion"
      // implementation "com.squareup.retrofit2:converter-gson:$retrofitVersion"

      // implementation "org.greenrobot:eventbus:$eventBusVersion"
      // implementation "com.github.bumptech.glide:glide:$glideVersion"
      // kapt "com.github.bumptech.glide:compiler:$glideVersion"
      // implementation "com.joooonho:selectableroundedimageview:$selectableRoundedImageViewVersion"
      testImplementation 'junit:junit:4.12'
      androidTestImplementation 'com.android.support.test:runner:1.0.2'
      androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'



      What I want is when I change my variant freeProdRelease or paidProdRelease and create release build then keystore file should be selected according to variant. for that I have setup code below



      if(variant.buildType.name == "release") 
      if(variant.productFlavors[0].name == "paid")
      android.buildTypes.release.signingConfig android.signingConfigs.paidProdRelease
      else
      android.buildTypes.release.signingConfig android.signingConfigs.freeProdRelease




      When I remove the above code then It gives error for release build and that is fine.



      But when I commented else block and creating release build it still works and doesn't give error for keystore file, It means each time keystore file will be used paidProdRelease that I don't want.



      if(variant.buildType.name == "release") 
      if(variant.productFlavors[0].name == "paid")
      android.buildTypes.release.signingConfig android.signingConfigs.paidProdRelease
      else
      // android.buildTypes.release.signingConfig android.signingConfigs.freeProdRelease




      What should I do to use different keystore file for respected version free/paid?










      share|improve this question
















      I have configured my app build.gradle with free and paid version with different keystores. look at the code below.



      apply plugin: 'com.android.application'
      apply plugin: 'kotlin-android'
      apply plugin: 'kotlin-android-extensions'
      apply plugin: 'kotlin-kapt'

      android
      signingConfigs
      freeProdRelease
      keyAlias 'free.prod.release.key'
      keyPassword 'password'
      storeFile file('F:/freeProdRelease.jks')
      storePassword 'password'

      paidProdRelease
      keyAlias 'paid.prod.release.key'
      keyPassword 'password'
      storeFile file('F:/paidProdRelease.jks')
      storePassword 'password'


      compileSdkVersion 28
      defaultConfig
      applicationId "com.example.the.app"
      minSdkVersion 21
      targetSdkVersion 28
      versionCode 1
      versionName "1.0"
      testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
      buildConfigField "long", "BUILD_DATE", "$System.currentTimeMillis()L"

      buildTypes
      release
      resValue "string", "some_api_key", "key for release"
      shrinkResources true //remove unused resources... will reduce APK size
      debuggable false
      useProguard true
      minifyEnabled true
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

      debug
      resValue "string", "some_api_key", "key for debug"
      debuggable true
      useProguard false
      minifyEnabled false
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'


      flavorDimensions "version", "environment"
      productFlavors
      free
      dimension "version"
      buildConfigField 'boolean', 'IS_PAID', 'false'
      versionNameSuffix "-free"
      applicationIdSuffix ".free"

      paid
      dimension "version"
      buildConfigField 'boolean', 'IS_PAID', 'true'
      versionNameSuffix "-paid"
      applicationIdSuffix ".paid"

      dev
      dimension "environment"
      versionCode 2000 + android.defaultConfig.versionCode
      versionNameSuffix "-dev"
      applicationIdSuffix ".dev"
      manifestPlaceholders = [appLabel: "The App - Dev"]

      prod
      dimension "environment"
      versionCode android.defaultConfig.versionCode
      manifestPlaceholders = [appLabel: "The App"]


      applicationVariants.all variant ->
      if(variant.buildType.name == "release")
      if(variant.productFlavors[0].name == "paid")
      android.buildTypes.release.signingConfig android.signingConfigs.paidProdRelease
      else
      android.buildTypes.release.signingConfig android.signingConfigs.freeProdRelease


      variant.outputs.each output ->
      def apkName = "theApp-v" + android.defaultConfig.versionName + "-c" +
      variant.productFlavors[1].versionCode

      apkName +=
      "-$variant.productFlavors[0].name-" +
      "$variant.productFlavors[1].name-$variant.buildType.name-$releaseTime()"
      apkName += ".apk"

      output.outputFileName = new File("$apkName")


      dexOptions
      javaMaxHeapSize "4g"

      configurations.all
      resolutionStrategy.eachDependency DependencyResolveDetails details ->
      def requested = details.requested
      if (requested.group == 'com.android.support')
      if (!requested.name.startsWith("multidex"))
      details.useVersion '27.1.1'




      testOptions
      unitTests.returnDefaultValues = true



      static def releaseTime()
      return new Date().format("yyyy-MMM-dd")


      dependencies
      implementation fileTree(include: ['*.jar'], dir: 'libs')
      implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
      implementation "com.android.support.constraint:constraint-layout:$constraintLayoutVersion"
      implementation "com.android.support:appcompat-v7:$supportLibraryVersion"
      implementation "com.android.support:recyclerview-v7:$supportLibraryVersion"
      implementation "com.android.support:design:$supportLibraryVersion"
      implementation "com.android.support:support-v4:$supportLibraryVersion"
      implementation "android.arch.persistence.room:runtime:$roomVersion"
      kapt "android.arch.persistence.room:compiler:$roomVersion"
      implementation "android.arch.lifecycle:extensions:$archLifecycleVersion"
      kapt "android.arch.lifecycle:compiler:$archLifecycleVersion"

      //dagger 2

      // implementation "com.google.dagger:dagger:$daggerVersion"

      // kapt "com.google.dagger:dagger-compiler:$daggerVersion"

      //to enable DaggerActivity, DaggerBroadcastReceiver, DaggerFragment etc classes

      // implementation "com.google.dagger:dagger-android:$daggerVersion"

      // kapt "com.google.dagger:dagger-android-processor:$daggerVersion"

      //support libraries with dagger 2

      // implementation "com.google.dagger:dagger-android-support:$daggerVersion"
      // implementation "com.google.code.gson:gson:$gsonVersion"
      // implementation "pub.devrel:easypermissions:$easyPermissionVersion"
      // implementation "com.github.ybq:Android-SpinKit:$spinKitVersion"

      //progress view
      // implementation "com.squareup.retrofit2:retrofit:$retrofitVersion"
      // implementation "com.squareup.retrofit2:converter-gson:$retrofitVersion"

      // implementation "org.greenrobot:eventbus:$eventBusVersion"
      // implementation "com.github.bumptech.glide:glide:$glideVersion"
      // kapt "com.github.bumptech.glide:compiler:$glideVersion"
      // implementation "com.joooonho:selectableroundedimageview:$selectableRoundedImageViewVersion"
      testImplementation 'junit:junit:4.12'
      androidTestImplementation 'com.android.support.test:runner:1.0.2'
      androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'



      What I want is when I change my variant freeProdRelease or paidProdRelease and create release build then keystore file should be selected according to variant. for that I have setup code below



      if(variant.buildType.name == "release") 
      if(variant.productFlavors[0].name == "paid")
      android.buildTypes.release.signingConfig android.signingConfigs.paidProdRelease
      else
      android.buildTypes.release.signingConfig android.signingConfigs.freeProdRelease




      When I remove the above code then It gives error for release build and that is fine.



      But when I commented else block and creating release build it still works and doesn't give error for keystore file, It means each time keystore file will be used paidProdRelease that I don't want.



      if(variant.buildType.name == "release") 
      if(variant.productFlavors[0].name == "paid")
      android.buildTypes.release.signingConfig android.signingConfigs.paidProdRelease
      else
      // android.buildTypes.release.signingConfig android.signingConfigs.freeProdRelease




      What should I do to use different keystore file for respected version free/paid?







      android gradle android-keystore






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Apr 5 at 13:54







      Amir Raza

















      asked Mar 27 at 13:09









      Amir RazaAmir Raza

      242 silver badges8 bronze badges




      242 silver badges8 bronze badges

























          0






          active

          oldest

          votes










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );














          draft saved

          draft discarded
















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55378028%2fmultiple-signing-configs-in-a-project-e-g-free-paid%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes




          Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.







          Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.




















          draft saved

          draft discarded















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55378028%2fmultiple-signing-configs-in-a-project-e-g-free-paid%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

          Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript