[FIXED] Kitkat kills: Not allowed to load local resource: file:///android_asset/webkit/android-weberror.png

Issue

I have an app that uses WebViews. I’ve changed my targetAPI from 18 to 19 and I’m currently testing on the new 4.4. For some reason I’m getting this error: Not allowed to load local resource: file:///android_asset/webkit/android-weberror.png on 4.4 but not on 4.3, does somebody have clue why?

Since I don’t really know where to start looking I can’t give the complete code. It might have something to do with the shouldInterceptRequest(Webview, String) method in the WebViewClient but I’m not really sure. If I know more, I’ll update the question.

Solution

“Not allowed to load local resource” is a security origin error. The KitKat WebView has stronger security restrictions and it seems like these are kicking in. FWIW I tried just loading a file:///android_asset URL and it worked fine.

Did you call any of the file-related WebSettings APIs (like setAllowFileAccess(false)) by any chance? Are you trying to load the resource from an https: URL?

Answered By – marcin.kosiba

Answer Checked By – Willingham (Easybugfix Volunteer)

Leave a Reply

(*) Required, Your email will not be published