Webview Showing Err_Cleartext_Not_Permitted Although Site Is Https

WebView showing ERR_CLEARTEXT_NOT_PERMITTED although site is HTTPS

Solution:

Add the below line in your application tag:

android:usesCleartextTraffic="true"

As shown below:

<application
....
android:usesCleartextTraffic="true"
....>

UPDATE: If you have network security config such as: android:networkSecurityConfig="@xml/network_security_config"

No Need to set clear text traffic to true as shown above, instead use the below code:

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
....
....
</domain-config>

<base-config cleartextTrafficPermitted="false"/>
</network-security-config>

Set the cleartextTrafficPermitted to true

Android Pie: WebView showing error for plain HTTP on some sites, even with usesClearTextTraffic=true

Solution:

As I've observed the Manifest.xml of yours, you have used the android:usesCleartextTraffic="true" in the <activity> tag.

As you can see in the Documentation of the activity tag, it does not offer any functionality as such in the syntax provided in the docs.

As you can see in the screenshot below, the description of the cleartexttraffic is quite straight forward.

About Clear Text Traffic

Also, if you look at the Documentation of the application tag, you will notice that android:usesCleartextTraffic is one of the attributes of the Application Tag.

So the only fix required here is to remove the attribute in from the activity tag and use it in the application tag and there is no activity tag support for android:usesCleartextTraffic.

Starting with Android 9 (Pie) Clear Text Traffic is disabled by default.

Hence, the solution would be:

<?xml version="1.0" encoding="utf-8"?>
<manifest ...>
<uses-permission android:name="android.permission.INTERNET" />
<application
...
android:usesCleartextTraffic="true"
...>
...
</application>
</manifest>

Try it, Please comment if you have any issues related to this.

Android Webview page could not be loaded with HTTP hyperlink because ERR_CLEARTEXT_NOT_PERMITTED

I resolved this problem by two options.

Option 1:

I removed one line from the AndroidManifest.xml file

android:networkSecurityConfig="@xml/network_security_config" 

Option 2:

Added http legacy library in the build.gradle file under defaultConfig column as

useLibrary 'org.apache.http.legacy'

I get ERR_CLEARTEXT_NOT_PERMITTED while running on my mobile. But it is running fine on webview and emulator

It just happened to me recently and if you are trying to connect from your device to any external server (since you mention about laravel echo, then I assume that you are trying to connect to an IP), then maybe you can try this.

If you notice, the network_security_config.xml located in "resources" folder will be copied into your android "app" folder

...

<platform name="android">
<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application" xmlns:android="http://schemas.android.com/apk/res/android">
<application android:networkSecurityConfig="@xml/network_security_config" />
</edit-config>
<resource-file src="resources/android/xml/network_security_config.xml" target="app/src/main/res/xml/network_security_config.xml" />
<allow-intent href="market:*" />
<icon density="ldpi" src="resources/android/icon/drawable-ldpi-icon.png" />
<icon density="mdpi" src="resources/android/icon/drawable-mdpi-icon.png" />
<icon density="hdpi" src="resources/android/icon/drawable-hdpi-icon.png" />
...
</platform>
...

Maybe try to modify network_security_config.xml file located in resources/android/xml/network_security_config.xml into :

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain>localhost</domain>
<domain>your_external_ip_here</domain>
</domain-config>
</network-security-config>

Hope this help.

WebView showing ERR_CLEARTEXT_NOT_PERMITTED although site is HTTPS

Solution:

Add the below line in your application tag:

android:usesCleartextTraffic="true"

As shown below:

<application
....
android:usesCleartextTraffic="true"
....>

UPDATE: If you have network security config such as: android:networkSecurityConfig="@xml/network_security_config"

No Need to set clear text traffic to true as shown above, instead use the below code:

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
....
....
</domain-config>

<base-config cleartextTrafficPermitted="false"/>
</network-security-config>

Set the cleartextTrafficPermitted to true



Related Topics



Leave a reply



Submit