I have a Xamarin.Forms application, for which I am able to debug in cleartext (http) mode, based on the inclusion of a network_security_config.xml file as follows:
<network-security-config>
<base-config cleartextTrafficPermitted="true" />
</network-security-config>
However, if I move the cleartextTrafficPermitted setting inside of a debug-overrides tag as follows, I get the error "Cleartext HTTP traffic to MYSITE is not permitted."
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<debug-overrides>
<base-config cleartextTrafficPermitted="true" />
</debug-overrides>
</network-security-config>
My application is running in debug mode. Even though app debugging was already working and mode was Debug, just in case I tried adding debuggable:true explicitly to the application tag in my AndroidManifest.xml, and have also tried adding (Debuggable = true) as a parameter in the ApplicationAttribute over my main application class declaration, but regardless of how I set the app to be debuggable, the base-config tag seems to be ignored if it's nested inside of a debug-overrides tag. Am I doing something wrong? Is there some other way to allow for HTTP to be permitted in debug mode but not in release mode?
CodePudding user response:
This likely happens because you are referring to the debug mode of Android and Xamarin doesn't use it in its debug mode.
I cannot fully confirm this, but this is the only possible reason I can think of. As Xamarin doesn't use Java virtual machine on Android to run it likely can't use debug that is intended for this virtual machine.
CodePudding user response:
android:usesCleartextTraffic="true"
put this line in application tag in manifest file.