Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set android:networkSecurityConfig only to single flavor

We deliver release apk build from a specific flavor(QA) to our QA team.

I would like to add networkSecurityConfig only to that flavor.

In order to do that I need to add next config to the manifest.

    <application android:networkSecurityConfig="@xml/network_security_config"... >
        ...
    </application>

Is that possible to add such config only to QA gradle flavor?

Preventing answers about <debug-overrides> it will not help me, since we delivers release build to QA.

like image 510
Rostyslav Roshak Avatar asked Jan 03 '23 23:01

Rostyslav Roshak


1 Answers

Sure.

Suppose the flavor is vanilla. In app/src/vanilla/AndroidManifest.xml, have an <application> element with your android:networkSecurityConfig attribute, and nothing else. You can also have the network_security_config resource be in that flavor (app/src/vanilla/res/xml/network_security_config.xml). Then, vanilla builds will merge in that attribute; other builds will not have it.

like image 194
CommonsWare Avatar answered Jan 06 '23 13:01

CommonsWare