Skip to content

Conversation

@klecko
Copy link
Contributor

@klecko klecko commented Feb 7, 2024

Hi,

When running the new zipalign-java-1.1.0.jar I am getting the following exception:

Exception in thread "main" java.lang.RuntimeException: com.iyxan23.zipalignjava.InvalidZipException: assumed central directory entry at 16346313 doesn't start with a signature
        at com.iyxan23.zipalignjava.Main.main(Main.java:48)
Caused by: com.iyxan23.zipalignjava.InvalidZipException: assumed central directory entry at 16346313 doesn't start with a signature
        at com.iyxan23.zipalignjava.ZipAlign.alignZip(ZipAlign.java:208)
        at com.iyxan23.zipalignjava.ZipAlign.alignZip(ZipAlign.java:53)
        at com.iyxan23.zipalignjava.Main.main(Main.java:46)

I believe the problem is here: we are reading from the file, but then here we are only seeking back if it's a .so file. The solution is to perform the seek in both cases.

@iyxan23
Copy link
Owner

iyxan23 commented Feb 8, 2024

Woah, a bit shocked that I missed that! Could you send the offending zip or a small reproduction?

Might as well replace the file.getFilePointer() to fileOffset + 28 so we wouldn't forget to seek back.

Thanks for the PR!

@klecko
Copy link
Contributor Author

klecko commented Feb 8, 2024

No problem!

The default native Android Studio project generates an offending apk: app-debug.zip.

@iyxan23
Copy link
Owner

iyxan23 commented Feb 8, 2024

Alright I've just tested it, works as intended. Thank you for the contribution! 😄

@iyxan23 iyxan23 merged commit fc24ceb into iyxan23:main Feb 8, 2024
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.

2 participants