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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With