Android Webview gives net::ERR_CACHE_MISS message

后端 未结 7 1815
深忆病人
深忆病人 2020-12-04 16:56

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 suc

7条回答
  •  独厮守ぢ
    2020-12-04 17:42

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

    1. Check if is present in manifest.xml. Make sure that it is nested under and not . Thanks to sajid45 and Liyanis Velazquez

    2. Ensure that you are using instead of the deprecated . Much thanks to alan_shi and creos.

    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);
    }
    

    or

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

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

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

    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.

提交回复
热议问题