DEV Community

Dimitrios Desyllas
Dimitrios Desyllas

Posted on

How I can apply a network_security_config.xml on specific variants and not in release one?

I want self-signed certificates to be applied in a specific variant and NOT in release or staging ones. Is there a way to do so?

More Info on:

In my build.gradle I have the follwing buildTypes:

buildTypes {
        release {
            //debuggable true
            minifyEnabled false
            signingConfig signingConfigs.config
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            buildConfigField "String", "SERVER_DOMAIN", "\"api.example.com\""
        }
        debug {
            minifyEnabled false
            buildConfigField "String", "SERVER_DOMAIN", "\"api.local\""
        }

        staging {
            initWith debug
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            buildConfigField "String", "SERVER_DOMAIN", "\"https://api.staging.example.com\""
        }

Discussion (0)