我有一个自定义错误页面要显示在 Web 视图中,该页面存储在默认资产文件夹中C:\Users\User\StudioProjects\Appname\app\src\main\assets\error.html
在我这样加载页面的onReceivedError
方法中WebViewClient
view.loadUrl("file:///android_asset/error.html");
当我编码和测试它时它工作正常,但奇怪的是,我再次测试它,Webview 显示此错误
The webpage at file:///android_asset/error.html could not be loaded because: net::ERR_FILE_NOT_FOUND
我尝试了https://stackoverflow.com/a/37994555/4722232的解决方案,它适用于 html,但我在其中有一个徽标并且遇到了同样的问题,并且在我得到的日志中
"Not allowed to load local resource: file:///android_asset/logo.png", source: about:blank (0)
任何帮助将不胜感激