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?

Xybernetics Xamarin WebView ERR_CLEARTEXT_NOT_PERMITTED

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

Xybernetics Xamarin WebView AndroidManifest.xml

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.

Xybernetics Xamarin WebView ERR_CLEARTEXT_NOT_PERMITTED network_security_config.xml AndroidManifest
Xybernetics Xamarin WebView ERR_CLEARTEXT_NOT_PERMITTED network_security_config AndroidManifest.xml

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://”.

https://youtu.be/38_UWl9_vIg

Reference