Is there a way to change gradle variable value based on selected productFlavor?

后端 未结 1 1147
我在风中等你
我在风中等你 2021-01-20 16:58

Below is my gradle example: I want to change STORE_FILE_PATH value dynamically based on selected productFlavors. Currently STORE_FILE_PATH is always overwriting it\'s value

相关标签:
1条回答
  • 2021-01-20 17:29

    You should define multiple signingConfigs and use it in different productFlavors

    signingConfigs{
       freeKey{}
       proKey{}
    }
    
    productFlavors {
        free {
    
            versionCode 1
            versionName "1.0.0"
    
            applicationId "com.example.free"
    
            buildConfigField "boolean", "IS_AD_ENABLED", "true"
            signingConfig signingConfigs.freeKey
        }
    
    
        pro {
    
            versionCode 1
            versionName "1.0.0 pro"
    
            applicationId "com.example.pro"
    
            buildConfigField "boolean", "IS_AD_ENABLED", "false"
    
            signingConfig signingConfigs.proKey
        }
    
    }
    
    0 讨论(0)
提交回复
热议问题