Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 991
dumazy Avatar asked Nov 15 '13 09:11

dumazy


1 Answers

I found that I had this problem on KitKat when I used webview.loadData(). If I instead used webview.loadDataWithBaseURL() (I used "file:///android_asset/" as the baseURL), then the problem went away.

The methods setAllowFileAccess(), setAllowFileAccessFromFileURLs(), and setAllowUniversalAccessFromFileURLs() did not have any affect that I could see.

like image 75
mikejonesguy Avatar answered Sep 28 '22 03:09

mikejonesguy