Android net::ERR_CLEARTEXT_NOT_PERMITTED

  • A+
所属分类:android 技巧

Android net::ERR_CLEARTEXT_NOT_PERMITTED

出错场景:

在Android APP中使用WebView控件后,访问网络,出现如下报错:

Android net::ERR_CLEARTEXT_NOT_PERMITTED

解决方案

AndroidManifest.xmlapplication中添加`android:usesCleartextTraffic="true"即可。

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="org.example.browserview">
    <uses-permission android:name="android.permission.INTERNET"/>
    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:usesCleartextTraffic="true"
        android:theme="@style/AppTheme">
        <activity android:name=".BrowserView">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>
百分购

发表评论

您必须才能发表评论!