Android ZipResourceFile to read APKExpansionFile n

2019-09-18 04:04发布

问题:

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 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

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.

Any hints?

回答1:

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.