我如何解决这个android WebView问题?

我如何解决这个android WebView问题?,android,android-webview,Android,Android Webview,我已将添加到AndroidManifest.xml。 <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.app" > <uses-permission android:name="android.permission.INTERNET"></uses-permission> <applicati

我已将
添加到
AndroidManifest.xml。

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.app"
    >
    <uses-permission android:name="android.permission.INTERNET"></uses-permission>
    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:networkSecurityConfig="@xml/network_security_config"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">

        <!--<uses-library android:name="org.apache.http.legacy" android:required="false"/>-->
        <activity android:name=".MainActivity" android:usesCleartextTraffic="true">

            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>
我对这个问题做了一些研究

所以我也把这个
network\u security\u config.xml
文件放在
res/xml/

<network-security-config>
    <domain-config cleartextTrafficPermitted="true">
        <!--<domain includeSubdomains="true">http://xxxxxxxx.com</domain>-->
        <domain includeSubdomains="true">http://www.smarterasp.net</domain>

    </domain-config>
</network-security-config>

http://www.smarterasp.net
但当我测试应用程序时,它只是在7.1.1版(API 25)上运行

否则,如果我在安卓8/9版本上测试,它将显示一个错误页面或白色屏幕


有人能帮忙吗?

尝试以下代码来解决此错误:将更改为smarterasp.net

网络安全配置.xml


youtube.com
smarterasp.net
显示

把这两行加起来

<application
      ..
        android:networkSecurityConfig="@xml/network_security_config"
        android:resizeableActivity="false"
       ..>

默认情况下,Android p需要HTTPS。这意味着,如果你在应用程序中使用未加密的HTTP请求,那么该应用程序在所有低于Android P的版本中都能正常工作

要避免此安全异常,请在
网络安全配置.xml
文件中尝试以下更改

网络安全配置.xml

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <domain-config cleartextTrafficPermitted="true">
        //  Add host of your download URL in below line. 
        //   ie. if url is  "https://www.google.com/search?source=...."
        //   then just add "www.google.com"
        <domain includeSubdomains="true">www.smarterasp.net</domain>
    </domain-config>
</network-security-config>

//在下面的行中添加下载URL的主机。
//即,如果url为“https://www.google.com/search?source=...."
//然后加上“www.google.com”
www.smarterasp.net

URL是什么?具体问题是什么?您只需在
网络安全配置.xml
文件中传递域即可。e、 g.
www.smarterasp.net
因此从中删除“http://”。@RahulKhurana该URL是由smarterasp.net托管的云,该服务正在使用HTTPTry将
android:usesCleartextTraffic=“true”
添加到
应用程序的
标记,并删除
android:networkSecurityConfig=“@xml/network\u security\u config”
line谢谢!但是现在错误页/空白页变为白色屏幕。。。没有其他东西可以显示,我能做什么?请稍等,可能是您的网站需要时间加载视图。因为我已经用我的模拟器检查了你的代码。我明白你的意思,谢谢!但是现在页面变为显示白色屏幕。。。你知道发生了什么事吗?
<application
      ..
        android:networkSecurityConfig="@xml/network_security_config"
        android:resizeableActivity="false"
       ..>
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <domain-config cleartextTrafficPermitted="true">
        //  Add host of your download URL in below line. 
        //   ie. if url is  "https://www.google.com/search?source=...."
        //   then just add "www.google.com"
        <domain includeSubdomains="true">www.smarterasp.net</domain>
    </domain-config>
</network-security-config>