Closed chitezh closed 2 years ago
Thanks for the quick review!
@ide what syntax would you prefer for all domains? a wildcard "*"?
On the latter question, maybe some more context here. We are developing against an expo development build that is distributed to all devs. It works when connecting from an emulator since 10.0.2.2
is whitelisted but throws an error when installed on a physical device connected from n
IPs. Thus, we are needing to open up the traffic to make this work for all.
Yes, I think "*"
would be appropriate. The type of the option would then be subdomains: string[] | '*'
. This way an empty array intuitively means "no domains" in which case we'd avoid creating the separate XML file and modifying AndroidManifest.xml altogether.
@ide please take a look when you can
Published in @config-plugins/detox@1.2.0
, thanks for the great contribution!
Great change, thank you @chitezh. But I believe your changes are causing a compilation error due to added whitespace in front of <?xml version="1.0" encoding="utf-8"?>
error
[stderr] Execution failed for task ':app:mergeDebugResources'.
[stderr] > A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
[stderr] > Android resource compilation failed
[stderr] /home/expo/workingdir/build/android/app/src/main/res/xml/network_security_config.xml:2: AAPT: error: XML or text declaration not at start of entity.
[stderr]
[stderr] /home/expo/workingdir/build/android/app/src/main/res/xml/network_security_config.xml: AAPT: error: file failed to compile.
Background
The app crashes when
detox
plugin is configured with an empty subdomain in cases where it's desired to allow all traffic.Cause
The configuration above generates an invalid xml resulting in a
Caused by: [android.security.net](http://android.security.net/).config.XmlConfigSource$ParserException: No domain elements in domain-config at: Binary XML file line #3
as it generatesFix
This PR inserts a
base-config
instead of adomain-config
when subdomains is "*" to allow all traffic.