Android ZipResourceFile读取APKExpansionFile不起作用 [英] Android ZipResourceFile to read APKExpansionFile not working

查看:705
本文介绍了Android ZipResourceFile读取APKExpansionFile不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用ZipResourceFile从APK扩展库中读取文件,该库将是未压缩的zip文件(尝试使用7z File Manager和WinRAR来使用存储方法进行压缩).

I'm trying to use ZipResourceFile to read from an APK expansion library that would be an Uncompressed zip file (Tried both 7z File Manager and WinRAR to compress with store method).

ZipResourceFile正确找到文件并将其传递给addPatchFile(String zipFileName)方法. 此方法不会引发任何错误,但会记录以下内容:

ZipResourceFile correctly finds the file and passes it to addPatchFile(String zipFileName) method. This method doesn't throw any error but logs the following:

01-17 18:21:49.226  11245-11245/it.[...] V/zipro﹕ +++ Found EOCD at index: 65535
01-17 18:21:49.226  11245-11245/it.[...] V/zipro﹕ +++ numEntries=-1 dirSize=9268245 dirOffset=487957082
01-17 18:21:49.226  11245-11245/it.[...] V/zipro﹕ +++ zip good scan -1 entries

因此,每次对getInputStream(String assetPath)的调用都将返回null.我检查了我尝试从存档中读取的每个文件,并正确显示了它们.

As a result every call to getInputStream(String assetPath) returns null. I checked every file I try to read from the archive and it's correctly present.

有任何提示吗?

推荐答案

问题在于zip文件包含的文件太少.显然ZipResourceFile无法处理此类存档.我使用ZipFile类解决了该问题,该类工作得很好,需要很少的代码修改. PS.似乎ZipFile也无法处理同一目录中的许多文件.将文件划分到更多目录中.

The problema was that The zip file contained too much little files. Apparently ZipResourceFile isn't able to deal with such archives. I solved using ZipFile class, which worked perfectly and required very little code modifications. PS. It seems even ZipFile can't deal with many files in the same directory. Divide your files in more directories.

这篇关于Android ZipResourceFile读取APKExpansionFile不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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