Is there a way to change the value of the gradle variable based on the selected Flavor product?

The following is an example of gradle: I want to change the STORE_FILE_PATH value dynamically based on the selected products. Currently, STORE_FILE_PATH always overwrites this value with the last defined product, Flavor. (In my case, it always becomes "/pro.jks")

Help find a solution. Thanks

def STORE_FILE_PATH = "";

android {
    productFlavors {
        free {

            versionCode 1
            versionName "1.0.0"

            applicationId "com.example.free"

            buildConfigField "boolean", "IS_AD_ENABLED", "true"
            STORE_FILE_PATH = "/free.jks"

        }


        pro {

            versionCode 1
            versionName "1.0.0 pro"

            applicationId "com.example.pro"

            buildConfigField "boolean", "IS_AD_ENABLED", "false"

            STORE_FILE_PATH = "/pro.jks"
        }

    }

    signingConfigs {
        signingConfig {
            keyAlias 'aa'
            keyPassword '123'
            storeFile file (STORE_FILE_PATH)
            storePassword '123'
        }
    }
}
+3
source share

Source: https://habr.com/ru/post/1657030/


All Articles