Reputation: 4838
I'm working on an Android app. For development purpose, I need to specify a network security config as specified in the official documentation. Obviously, it is referenced in the AndroidManifest.xml
.
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">aaa.bb.cc.dd</domain>
</domain-config>
</network-security-config>
Now, I need to remove this file (and its reference in the manifest too) in the release version of my app. How can I achieve this? Thank you in advance.
Upvotes: 9
Views: 4575
Reputation: 1107
Even better than duplicating the AndroidManifest.xml
, is to create an extra xml
file in the same on the app/src/debug
path and Android will automatically recognise that one during a debug
build.
So, if you currently have a network policy xml file located on:
app/src/main/res/xml/network_policy.xml
You would simply create another xml
resource directory under app/src/debug
and then another network_policy.xml
file within that directory:
app/src/debug/res/xml/network_policy.xml
And then you just write the network policy for each build variant accordingly.
Upvotes: 16
Reputation: 561
You simply create another AndroidManifest.xml
and put in in the debug folder structure, something like app/src/debug
, so this manifest property will be used in debug build, but the real manifest will be used in prod build.
Upvotes: 8