Android Webview 给出 net::ERR_CACHE_MISS 消息 [英] Android Webview gives net::ERR_CACHE_MISS message

查看:65
本文介绍了Android Webview 给出 net::ERR_CACHE_MISS 消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我构建了一个 Web 应用程序,并希望创建一个具有显示我的 Web 应用程序的 Web 视图的 Android 应用程序.按照 Google Developer 的说明创建应用后,我成功地将它安装在我的手机上,Android 5.1.1.

I built a web app and wants to create an android app that has a webview that shows my web app. After following the instructions from Google Developer to create an app, I successfully installed it on my phone with Android 5.1.1.

但是,当我第一次运行该应用程序时,webview 会显示以下消息:

However, when I run the app for the first time, the webview shows the message:

网页不可用

无法加载位于 [Lorem Ipsum URL] 的网页:

The Web page at [Lorem Ipsum URL] could not be loaded as:

net::ERR_CACHE_MISS

net::ERR_CACHE_MISS

推荐答案

答案汇总!我想将所有答案合并为一个综合答案.

Answers assembled! I wanted to just combine all the answers into one comprehensive one.

1. 检查 是否存在于 manifest.xml.确保它嵌套在 而不是 下.感谢 sajid45利亚尼斯·委拉斯开兹

1. Check if <uses-permission android:name="android.permission.INTERNET" /> is present in manifest.xml. Make sure that it is nested under <manifest> and not <application>. Thanks to sajid45 and Liyanis Velazquez

2. 确保您使用的是 <uses-permission android:name="android.permission.INTERNET"/> 而不是已弃用的 <uses-permission android:name="android.permission.internet"/>.非常感谢 alan_shi克里奥斯.

2. Ensure that you are using <uses-permission android:name="android.permission.INTERNET"/> instead of the deprecated <uses-permission android:name="android.permission.internet"/>. Much thanks to alan_shi and creos.

3.如果最低版本低于 KK,请检查您是否有

3. If minimum version is below KK, check that you have

if (18 < Build.VERSION.SDK_INT ){
    //18 = JellyBean MR2, KITKAT=19
    mWeb.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
}

if (Build.VERSION.SDK_INT >= 19) {
        mWebView.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
}

因为正确的 webview 只在 KK (SDK 19) 中添加.感谢 DevavrataMike ChanSeong KimLiyanis Velazquez

because proper webview is only added in KK (SDK 19). Thanks to Devavrata, Mike ChanSeong Kim and Liyanis Velazquez

4. 确保您没有 webView.getSettings().setBlockNetworkLoads (false);.感谢 TechNikh 指出这一点.

4. Ensure that you don't have webView.getSettings().setBlockNetworkLoads (false);. Thanks to TechNikh for pointing this out.

5.如果所有其他方法都失败,请确保您的 Android Studio、Android SDK 和模拟器映像(如果您正在使用)已更新.如果您仍然遇到问题,只需打开一个新问题并在您的网址下方发表评论.

5. If all else fails, make sure that your Android Studio, Android SDK and the emulator image (if you are using one) is updated. And if you are still meeting the problem, just open a new question and make a comment below to your URL.

这篇关于Android Webview 给出 net::ERR_CACHE_MISS 消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆