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

On Android 12 devices, The file generated with the patch was different from the origin file; #183

Open
guzhonL opened this issue Mar 22, 2022 · 16 comments

Comments

@guzhonL
Copy link

guzhonL commented Mar 22, 2022

On Android 12 devices(Almost all of android 12 devices), I found in certain cases the file generated with the patch was different from the origin file;

env: android os version:android12,archive-patcher version:v1.1

my test files as flows:
old file:19onlyjar.zip
patch file:patch-onlyjar.zip
origin file:20onlyjar-ori.zip

how to reproduce:
1、unzip patch file first;
2、apply the patch with the following code:
` public static void applyPatch(File oldFile, File patchFile, File newFile, File tempDir) throws IOException {

   if(!tempDir.exists()){
       tempDir.mkdirs();
   }
    BufferedInputStream bufferedPatchIn = null;
    BufferedOutputStream bufferedNewOut = null;
    try{
        FileByFileV1DeltaApplier applier = new FileByFileV1DeltaApplier(tempDir);
        FileInputStream patchIn = new FileInputStream(patchFile);
        bufferedPatchIn = new BufferedInputStream(patchIn);
        FileOutputStream newOut = new FileOutputStream(newFile);
        bufferedNewOut = new BufferedOutputStream(newOut);
        applier.applyDelta(oldFile, bufferedPatchIn, bufferedNewOut);
        bufferedNewOut.flush();
    }finally {
        if(bufferedPatchIn != null){
            bufferedPatchIn.close();
        }
        if(bufferedPatchIn != null){
            bufferedPatchIn.close();
        }
    }
}`

3、compare the md5 between the origin file and the generated file in step2

19onlyjar.zip
patch-onlyjar.zip
20onlyjar-ori.zip

@sun804336516
Copy link

I also encountered this problem

@hamidmansouri
Copy link

me too

1 similar comment
@GreenPepperForPotato
Copy link

me too

@aravindakv
Copy link

I also encountered this problem. Its issue with only Android 12, works fine in linux PC.

@hamid97m
Copy link

hamid97m commented Oct 10, 2022

Any solution? @pspencil

@pspencil
Copy link
Collaborator

Any solution? @pspencil

Sorry I don't work on this anymore. I have some vague memories of Android 12 changing the underlying zip library. Perhaps you can try explicitly linking in your own zip lib. (Not sure how to do that though)

@sisong
Copy link

sisong commented Oct 18, 2022

My solution 1: ApkDiffPatch; MIT license; C++; linking own zlib; only for own apk; (can't be used by Android app store, because it requires re-signing apks before diff);
My solution 2: sfpatcher; Business license; C++; linking own zlib; is designed for Android app store; patch speed up by a factor of xx than archive-patcher & run with O(1) memory & not need temp files & support large game apk & support android4.1--android13.

@aravindakv
Copy link

How to integrate sfpatcher; in android app? are there jar/aar files available?

@hamid97m
Copy link

hamid97m commented Oct 19, 2022

Do you think the problem could be solved by changing the Zlib version in server side for generating diff?@pspencil
If the answer is no, have you any idea about how link own Zlib (1.2.12) in my project? the archive-patcher is using deflater and changing the deflater is not possible, it is loading the zlib in static block. @pspencil

@hamid97m
Copy link

I finally fixed this problem; in the near future, I will make a PR

@ityancs
Copy link

ityancs commented Apr 6, 2023

I finally fixed this problem; in the near future, I will make a PR

Can you share how to fix it?more PR details?

@ityancs
Copy link

ityancs commented Apr 19, 2023

finally I copy the zlib jni code(below android 12) solved

@aravindakv
Copy link

finally I copy the zlib jni code(below android 12) solved

Can you submit changes and share PR details?

@ityancs
Copy link

ityancs commented Apr 20, 2023

finally I copy the zlib jni code(below android 12) solved

Can you submit changes and share PR details?

copy the zlib c code and use custom Deflater bind the custom zlib with jni。
https://cs.android.com/android/platform/superproject/+/android-10.0.0_r47:external/zlib/src/deflate.c
https://cs.android.com/android/platform/superproject/+/master:libcore/ojluni/src/main/native/Deflater.c

@hamid97m
Copy link

It's fixed in my PR

@berlix
Copy link

berlix commented May 20, 2023

Inspired by @hamid97m's solution, we addressed this issue by bundling zlib 1.2.13 binaries (the currently latest version) and creating a version of Deflater that uses those.

Sources: https://github.com/EIDU/archive-patcher-android

The library is on Maven Central. See the repo's README.md for usage instructions.

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

No branches or pull requests

10 participants