Webview loading local file yields stock 404 screen

Issue

I am testing a working app for backwards compatibility.

I am loading a site into a webview from the local filesystem:

protected void onCreate(Bundle savedInstanceState) {
    // set up webview etc
    // load 
    mWebView.loadUrl("file:////android_asset/index.html");
}

In Jelly Bean this initially loads the stock 404 screen (Webpage not available) with a link to that path. Clicking the path loads the site.

At a loss of what to do hereā€¦

Solution

You’ve got one slash too many in the uri. It should be file:///android_asset/index.html.

Answered By – SpaceBison

Leave a Comment