Home » Android » Android Webview gives net::ERR_CACHE_MISS message

Android Webview gives net::ERR_CACHE_MISS message

Posted by: admin March 11, 2020 Leave a comment

Questions:

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.

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

Web page not available

The Web page at http://www.google.com.sg could not be loaded as:

net::ERR_CACHE_MISS

After searching for a while on Google and trying out solutions, I am still stuck on this error. I have included all permissions needed so it shouldn’t be beacuse of that. My Android Studio is also fully updated so it is not because of that.

How to&Answers:

I solved the problem by changing my AndroidManifest.xml.

old  : <uses-permission android:name="android.permission.internet"/>
new: <uses-permission android:name="android.permission.INTERNET"/>

Answer:

I tried above solution, but the following code help me to close this issue.

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

Answer:

For anything related to the internet, your app must have the internet permission in ManifestFile. I solved this issue by adding permission in AndroidManifest.xml

<uses-permission android:name="android.permission.INTERNET" />

Answer:

Use

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

It should solve the error.

Answer:

I have found an answer to my problem. It was because I accidentally nested the permission in the application in AndroidManifest.xml.

@Bidhan Although I did not use what commented, thank you for your quick response

Answer:

Also make sure your code doesn’t have true for setBlockNetworkLoads

webView.getSettings().setBlockNetworkLoads (false);