sisong / ApkDiffPatch

a C++ library and command-line tools for Zip(Jar,Apk) file Diff & Patch; create minimal delta/differential; support Jar sign(apk v1 sign) & apk v2,v3 sign .
MIT License
310 stars 49 forks source link

ZipPatch问题 #56

Closed Picasso1990 closed 4 years ago

Picasso1990 commented 4 years ago

我在Android上使用patch合成一个new.apk,但是这个new.apk却在android中读取不出来所有的ZipEntry: 使用如下程序读取不出来: ZipFile zipFile = new ZipFile(filePath); InputStream inputStream = new BufferedInputStream(new FileInputStream(filePath)); ZipInputStream zipInputStream = new ZipInputStream(new FileInputStream(filePath)); ZipEntry zipEntry; HashMap<String, InputStream> inputStreamHashMap = new HashMap<>(); while ((zipEntry = zipInputStream.getNextEntry()) != null) { if (zipEntry.isDirectory()) { continue; } else { String name = zipEntry.getName(); Log.d(TAG, "-------" + name); }

请问是什么原因呢?

sisong commented 4 years ago

"合成一个new.apk" 首先,分析这个文件本身有没有问题,并且确认(diff时的)本地的new.apk是否有区别; 如果本地new.apk也有同样问题,那再看看apkNormalized处置之前的new.apk是否有同样问题;

Picasso1990 commented 4 years ago

该问题已解决,apk都没问题,是JDK中的ZipInputStream遗留的问题,在某些情况下ZipInputStream会导致文件丢失。