-
Notifications
You must be signed in to change notification settings - Fork 109
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
Wrong output when number of dex files increases #99
Comments
Yeah something is definitely wrong there, it's clearly not attributing space correctly in the second APK. How are you creating the APK? Are you using an external tool designed for obfuscation? You can tell it still sees the dex files, but their size is returning 1B somehow (hence the 2B total), potentially due to a corrupted zip structure (at least in the eyes of the JDK ZIP implementation). The 196B compressed size is all the ZIP metadata like the file name, path, timestamps, etc. being added to 2B. Are you able to share the second APK? Or the tools you're using so I can try to reproduce? Also what version of Java are you running diffuse with? |
Just plain Everything is running the same version of Java:
|
I have a similar issue when a build is signed using
Also, the Wikipedia page about ZIP format that you provided in the comments denotes that the local header of a file stored in a zip archive contains information about the file's compressed and uncompressed size only in case if the file's format is not ZIP64: |
I don't fully understand why, but I just learned that negative values (both for size and compressed size) are produced only when using |
Update dependency org.jetbrains.kotlin.jvm to v1.7.10
@shamilovstas Thank you for the reproducer! I see the same behavior. Indeed the zip format will use -1 as values for both the compressed and uncompressed size when a zip64 record is present in the extras, Looking into it. |
Okay so the problem is that the creation of the zip was streamed, which means the sizes were not known when the local file header was written (as it precedes the data). When you are streaming, you set bit 3 (0x08) of the general flags which indicates that the data will be followed by a data descriptor record containing the final size information. If we dump a jarsigned zip we see this is the case:
|
@mateuszkwiecinski Using All we need to do is skip the zip entry's contents so that the trailing data descriptor can be parsed and the correct values become available. Bonus: this also allows increasing the precision of the size attribution since we know a data descriptor is present. |
This is output for diffuse when comparing APK before and after adding a big library with native libs and whatnot (unique numbers are way off because of R8):
Note
DEX#count
row, which shows increased DEX count, yetAPK#dex
row shows dex size has significantly decreased. Also total compressed file size is much lower than in reality. Here's what AS shows when inspecting new apk file:For comparison, old apk seems to be aligned with diffuse output:
![image](https://user-images.githubusercontent.com/3951580/93894961-95460a00-fcef-11ea-8f45-888012b93fa5.png)
The text was updated successfully, but these errors were encountered: