简体   繁体   English

由于 ERR_CLEARTEXT_NOT_PERMITTED,Android Webview 页面无法加载 HTTP 超链接

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

I'm working on an android native app where I'm loading a HTML string in WebView from strings.xml which has some hyperlink texts all.我正在开发一个 android 本机应用程序,我正在从 strings.xml 在 WebView 中加载一个 HTML 字符串,其中包含一些超链接文本。 One hyperlink out of all of them is having http url and which is not getting opened within webView and throwing error as ERR_CLEARTEXT_NOT_PERMITTED .所有这些中的一个超链接是http url 并且它没有在 webView 中打开并抛出错误为ERR_CLEARTEXT_NOT_PERMITTED I'm already using usesCleartextTraffic settings in my app but still unable to use that.我已经在我的应用程序中使用了usesCleartextTraffic设置,但仍然无法使用它。

AndroidManifest.xml AndroidManifest.xml

 <application
    android:name=".com.app"
    android:allowBackup="false"
    android:icon="@mipmap/ic_hp_launcher"
    android:networkSecurityConfig="@xml/network_security_config"
    android:roundIcon="@mipmap/ic_hp_launcher_round"
    android:supportsRtl="false"
    android:theme="@style/AppTheme"
    android:usesCleartextTraffic="true">

network_security_config.xml network_security_config.xml

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<debug-overrides>
    <trust-anchors>
        <!-- Trust user added CAs while debuggable only -->
        <certificates src="user" />
        <certificates src="system" />
    </trust-anchors>
</debug-overrides>

<base-config cleartextTrafficPermitted="true">
    <trust-anchors>
        <certificates src="system" />
    </trust-anchors>
</base-config>

<domain-config cleartextTrafficPermitted="true">
    <!-- Make sure your URL Server here -->
    <domain includeSubdomains="true">https://xxxxxx.base.url</domain>
    <domain includeSubdomains="true">http://.xxxx.org</domain>
    <trust-anchors>
        <certificates src="user"/>
        <certificates src="system"/>
    </trust-anchors>
</domain-config>

UIClass.kt UIClass.kt

//Enabling JS for allowing all hyperlinks
    binding.webView.settings.javaScriptEnabled = true
    binding.webView.settings.javaScriptCanOpenWindowsAutomatically = true

build.gradle构建.gradle

minSdkVersion 28
targetSdkVersion 30

Please let me know if I'm doing any mistake.如果我做错了什么,请告诉我。 Thanks in advance.提前致谢。

I removed one line from the AndroidManifest.xml file我从AndroidManifest.xml文件中删除了一行

android:networkSecurityConfig="@xml/network_security_config" 

and it worked for me.它对我有用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Android WebView 加载失败 (net::ERR_CLEARTEXT_NOT_PERMITTED) - Android WebView failed to load (net::ERR_CLEARTEXT_NOT_PERMITTED) Android 9 上的 ERR_CLEARTEXT_NOT_PERMITTED,允许域明文 - ERR_CLEARTEXT_NOT_PERMITTED on Android 9, with domain cleartext permitted Android 中的离子 5/电容器 ERR_CLEARTEXT_NOT_PERMITTED - Ionic 5/Capacitor ERR_CLEARTEXT_NOT_PERMITTED in Android 为什么 HTTP 流量的明文错误 ERR_CLEARTEXT_NOT_PERMITTED 持续存在? - Why is the error ERR_CLEARTEXT_NOT_PERMITTED with cleartext for the HTTP traffic persistent? 离子“ERR_CLEARTEXT_NOT_PERMITTED” - Ionic "ERR_CLEARTEXT_NOT_PERMITTED" WebView 在 HTTPS 网址上显示 net::ERR_CLEARTEXT_NOT_PERMITTED - WebView shows net::ERR_CLEARTEXT_NOT_PERMITTED on HTTPS url “网页不可用,无法加载位于http://xxx.xxx.xxx.xx:3000 / pgSimulator / axis / redirect的网页。 网:: ERR_CLEARTEXT_NOT_PERMITTED” - “Webpage not available, the webpage at http://xxx.xxx.xxx.xx:3000/pgSimulator/axis/redirect could not be loaded. net::ERR_CLEARTEXT_NOT_PERMITTED” 净::ERR_CLEARTEXT_NOT_PERMITTED 离子 4 - net::ERR_CLEARTEXT_NOT_PERMITTED ionic 4 我在手机上运行时收到 ERR_CLEARTEXT_NOT_PERMITTED。 但它在 webview 和模拟器上运行良好 - I get ERR_CLEARTEXT_NOT_PERMITTED while running on my mobile. But it is running fine on webview and emulator Android 9:webview 中不允许明文 HTTP 流量 - Android 9: Cleartext HTTP traffic not permitted in webview
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM