My app has free and paid flavours. Right now we are adding tests the to paid flavour that run in a mock server, we need to communicate with it in cleartext so are trying to add a network security config only in androidTestPaid (we don't have one in the main source root). Unfortunately the config seems to be completely ignored.
androidTestPaid/AndroidManifest.xml
<manifest ...>
<application
tools:node="merge"
android:networkSecurityConfig="@xml/network_security_config"
android:usesCleartextTraffic="true"
... />
</application>
<instrumentation android:name="...CustomTestRunner" ... />
</manifest>
androidTestPaid/res/xml/network_security_config.xml
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">127.0.0.1</domain>
</domain-config>
</network-security-config>
In our gradle files we do not do anything with source sets for flavour-specific android test, but we do for the base android test. Could that lead to problems?
build.gradle
android {
sourceSets {
androidTest {
java.srcDirs = ['src/androidTest/java', 'src/testShared/java']
testOptions {
animationsDisabled = true
}
}
...
}
...
}
What would stop this configuration from being picked up in our tests?