Learn how to resolve Xamarin WebView ERR_CLEARTEXT_NOT_PERMITTED error message.
If you have a WebView in your android app that end users can browse to whatever site they want, and when you run your app you get the error message ERR_CLEARTEXT_NOT_PERMITTED. How do you resolve the Xamarin WebView showing ERR_CLEARTEXT_NOT_PERMITTED error message?
Watch my video on how you would remediate this easily. Spoiler Alert!! You will have to add the following line to your program… Where to set android:usesCleartextTraffic=”true” in Xamarin android?…. well to your AndroidManifest.xml file.
android:usesCleartextTraffic=”true”
This is what the AndroidManifest.xml file should look like after you add the usesCleartextTraffic
If you are new to Xamarin… Xamarin is an open-source platform for building modern and computing applications for Apple iOS, Android and Microsoft Windows with .NET. Xamarin is an abstraction layer that manages communication of shared code with underlying platform code. It is programmed using the Microsoft Visual Studio
Ok, ok, ok. I demonstrated how to resolve this problem by editing the AndroidManifest.xml file, however, there are other 3 ways to resolve this problem.
Option 1 is of course the AndroidManifest.xml file as demonstrated on my YouTube video.
Option 2 would be to edit/create a network_security_config.xml file and edit the AndroidManifest.xml, as shown below.
To save you from typing below are the codes.
network_security_config.xml
www.xybernetics.com(OR CHANGE THIS TO YOUR DOMAIN)
AndroidManifest.xml files
Option 3. Simply try to use webpages with “https://” in the URL, instead of “http://”.
Reference
- WebView showing ERR_CLEARTEXT_NOT_PERMITTED although site is HTTPS
- Where to set [Application(UsesCleartextTraffic = true)] in xamarin android
- Android M and the war on cleartext traffic
- Android 8: Cleartext HTTP traffic not permitted
- How to fix ‘Cleartext HTTP traffic to x not permitted’ in xamarin android
- Cleartext HTTP traffic not permitted