未知的错误铬-6 Android的web视图加载本地图像时 [英] Unknown Chromium Error -6 when loading local images in Android Webview

查看:142
本文介绍了未知的错误铬-6 Android的web视图加载本地图像时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的工作是下载的zip文件中的工作灯工程,解压缩它,并存储在该平台的具体文件目录中的文件(在iOS设备上的 NSDocumentDirectory ,在Android上我使用 getFilesDir())。该文件包含一个HTML文件和多个图像,位于子目录(媒体)的。下载并解压缩在两个平台上的精品工程。在解压缩过程结束后,我加载HTML文件的内容到现有的div(因为这是一个工作灯的应用程序,一切都在一个HTML文件)。

I'm working on a Worklight project that downloads a zip file, unpacks it, and stores the files in the specific documents directory of the platform (in iOS that's NSDocumentDirectory, on Android I'm using getFilesDir()). The file consists of one HTML file and several images, located in a sub directory (media). Downloading and unzipping works fine on both platforms. After the unzip process I'm loading the contents of the HTML file into an existing div (since this is a Worklight app, everything is in one HTML file).

下面的事情变得复杂:
在HTML文件中的图像标记源,我已经下载的是相对于HTML文件(例如,媒体/ myimage.jpg')。当我注入HTML文件进入工作灯HTML文件(位于应用程序包/包),基本URL变化和图像不能发现任何地方。我解决了这个问题通过编写重写下载的HTML文件中的所有图像标记本地函数指向绝对URL(iOS版:的/ var /移动/应用/<标识符> /文件/ ,Android的: /数据/数据​​/<&ID GT; /文件/ )。这适用于iOS很好,但在Android上它会导致HTML以部分仅负载。 LogCat中然后显示:

Here things become complicated: The image tag sources in the HTML file that I've downloaded are relative to the HTML file (e.g. 'media/myimage.jpg'). When I inject the HTML file into the Worklight HTML file (which is located in the App bundle/package), the base URL changes and the images can't be found anywhere. I fixed this by writing native functions that rewrite all the image tags in the downloaded HTML file to point to an absolute URL (iOS: /var/mobile/Applications/<identifier>/Documents/, Android: /data/data/<id>/files/). This works fine on iOS, but on Android it causes the HTML to only load partially. LogCat then shows:

Unknown chromium error: -6

如果我把文件,因为它们的HTML正确加载,但显然与破碎的形象。我也试图改变的URL 的file:///数据/数据​​/&LT;&ID GT; /文件/ [...] ,这也导致HTML不完全加载。我真的有不知道是什么原因造成了这个问题。该应用程序已经拥有了 WRITE_EXTERNAL_STORAG​​E 的权限。

If I keep the files as they are, the HTML loads correctly, but obviously with broken images. I've also tried to change the URLs to file:///data/data/<id>/files/ [...], which also causes the HTML to not load completely. I have really no idea what is causing this problem. The app already has the WRITE_EXTERNAL_STORAGE permission.

有没有人有一个想法如何解决这一问题?谢谢!

Does anyone have an idea how to fix this? Thank you!

推荐答案

原来这个错误是由具有比宽度1500px较大的图像造成的。缩放下来后,错误消失。必须与Android的web视图的一个问题,我猜。

Turns out this error was caused by having images that are larger than 1500px in width. After scaling them down, the error disappears. Must be a problem with the Android webview, I guess.

这篇关于未知的错误铬-6 Android的web视图加载本地图像时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆