问题描述
我有一个使用WebViews的应用程序。我已经改变了我targetAPI从18到19,我目前正在测试的新4.4。出于某种原因,我得到这个错误:不允许加载本地资源:文件:///android_asset/webkit/android-weberror.png
4.4上而不是在4.3 ,是否有人有线索,为什么?
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?
因为我真的不知道从哪里开始找我不能给出完整的code。它可能有一些做的WebViewClient的 shouldInterceptRequest(web视图,字符串)
方法,但我真的不知道。如果我知道更多,我会更新的问题。
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.
推荐答案
不允许加载本地资源是一个安全的起源错误。在奇巧的WebView具有更强的安全性限制,好像这些都是踢FWIW我想只是加载一个文件:/// android_asset URL,它能正常工作
"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.
你有没有任何机会调用任何文件相关的API WebSettings(如setAllowFileAccess(假))?你们是不是从一个HTTPS加载资源:网址
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?
这篇关于奇巧击杀不允许加载本地资源:文件:///android_asset/webkit/android-weberror.png的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!