Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#422]:Android R系统上,安装异常 #430

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

GainLee
Copy link

@GainLee GainLee commented Sep 27, 2020

原因:gradle 3.5.0+时向apk写入apkhash文件存在再压缩操作,而Android R不允许对resources.arsc进行压缩
解决方案:去掉写apkhash的操作,这块属于补丁加载策略的逻辑,正如wiki所说“对于补丁的加载策略不同的业务方有着不同的需求”,各业务去定制加载策略即可。

Signed-off-by: Gain perfecter.gen@gmail.com

原因:gradle 3.5.0+时向apk写入apkhash文件存在再压缩操作,而Android R不允许对resources.arsc进行压缩
解决方案:去掉写apkhash的操作,这块属于补丁加载策略的逻辑,正如wiki所说“对于补丁的加载策略不同的业务方有着不同的需求”,各业务去定制加载策略即可。

Signed-off-by: Gain <perfecter.gen@gmail.com>
@Joehzd
Copy link

Joehzd commented Apr 19, 2022

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) {
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants