Robust
Robust copied to clipboard
[#422]:Android R系统上,安装异常
原因:gradle 3.5.0+时向apk写入apkhash文件存在再压缩操作,而Android R不允许对resources.arsc进行压缩 解决方案:去掉写apkhash的操作,这块属于补丁加载策略的逻辑,正如wiki所说“对于补丁的加载策略不同的业务方有着不同的需求”,各业务去定制加载策略即可。
Signed-off-by: Gain [email protected]
createHashFile2方法中,将解包前的entry.method 应用到新的zipEntry中即可 def static void createHashFile2(String filePath, String fileName, String content) throws IOException { ZipInputStream zis = new ZipInputStream(new FileInputStream(filePath)); ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(filePath + ".temp")); ZipEntry entry = zis.getNextEntry(); while (entry != null) { def zipEntry = new ZipEntry(entry.getName()) //重点是这步 zipEntry.setMethod(entry.method) zos.putNextEntry(zipEntry); byte[] bytes = IOUtils.toByteArray(zis); zos.write(bytes); entry = zis.getNextEntry(); } ZipEntry e = new ZipEntry(fileName); zos.putNextEntry(e); zos.write(content.getBytes()); zos.closeEntry();
zos.flush();
zos.close();
zis.close();
try {
new File(filePath).delete();
new File(filePath + ".temp").renameTo(new File(filePath));
} catch (Exception ex) {
}
}