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.
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
Class Java.Util.Map Has Generic Type Parameters, Please Use Generictypeindicator Instead
Android: Display Image from Sd Card
How to Find the Logs on Android Studio
Check Whether Activity Is Active
Sqlite Returned an Error Code of 14
Receive Push Notifications on One Android App from Two Firebase Projects
File Res/Drawable/Abc_Ic_Ab_Back_Material.Xml from Drawable Resource Id #0X7F020016
Gcm Service_Not_Available on Android 2.2
Listview in Arrayadapter Order Get's Mixed Up When Scrolling
Android Keyboard Hides Edittext
Disabling Android O Auto-Fill Service for an Application
Android: Disable Soft Keyboard at All Edittexts
Android - How to Enable Autostart Option Programmatically in Xiaomi Devices
How to Store SQLite Database Directly on Sdcard
Android Exception: Did You Forget to Call 'Public Void Setup (Localactivitymanager Activitygroup)'
Android Studio:Unmappable Character for Encoding Utf-8