Skip to content

Conversation

@BarbossHack
Copy link

First time contributor checklist

Contributor checklist

  • Desktop, Linux (fedora 42)
  • My contribution is fully baked and ready to be merged as is
  • I ensure that all the open issues my contribution fixes are mentioned in the commit message of my first commit using the Fixes #1234 syntax

Description

Short

This improves the reproducible script so that it shows all mismatches, not only the first one.

Long

The modifications are located in the three main functions of apkdiff.py

def compare(apk1, apk2)

Instead of comparing entry names and antry contents using a single logical AND, both comparisons are now always executed and their results returned. This allows mismatches from both comparisons to be displayed.

def compare_entry_names(zip1: ZipFile, zip2: ZipFile)

Instead of returning on the first name mismatch, the function now checks which entry names are (or are not) present in both APKs, displays them, and then returns False. This makes it easier to see all entry name mismatches.

def compare_entry_contents(zip1: ZipFile, zip2: ZipFile)

The function no longer returns immediately when entry lengths mismatch. It continues checking the contents of all entries and returns False afterward.

@BarbossHack
Copy link
Author

Example

(using protonmail apk just to show how many mismatch the script misses)

Before

$ uv run apkdiff.py ProtonMail-7.7.0_16219.apk ProtonMail-7.7.1_16244.apk
Comparing: 
        ProtonMail-7.7.0_16219.apk
        ProtonMail-7.7.1_16244.apk

Unzipping...
Comparing zip entry names...
Manifest lengths differ!
Sorted manifests don't match, META-INF/androidx.compose.runtime_runtime-retain.version vs META-INF/androidx.compose.runtime_runtime-saveable.version
APKs don't match!

After

uv run apkdiff.py ProtonMail-7.7.0_16219.apk ProtonMail-7.7.1_16244.apk
Comparing: 
        ProtonMail-7.7.0_16219.apk
        ProtonMail-7.7.1_16244.apk

Unzipping...
Comparing zip entry names...
Manifest lengths differ! 2375 vs 2372
Files present only in ProtonMail-7.7.0_16219.apk:
  - META-INF/androidx.compose.runtime_runtime-retain.version
  - META-INF/androidx.window_window-core.version
  - META-INF/androidx.window_window.version
  - META-INF/ui.kotlin_module
Files present only in ProtonMail-7.7.1_16244.apk:
  - META-INF/ui_release.kotlin_module
Comparing zip entry contents...
APK info lists of different length! 2375 vs 2372
APKs differ on file META-INF/version-control-info.textproto! Files extracted to the mismatches/ directory.
APKs differ on file assets/dexopt/baseline.prof! Files extracted to the mismatches/ directory.
APKs differ on file assets/dexopt/baseline.profm! Files extracted to the mismatches/ directory.
APKs differ on file classes.dex! Files extracted to the mismatches/ directory.
APKs differ on file classes2.dex! Files extracted to the mismatches/ directory.
[...]
APKs differ on file res/zc.xml! Files extracted to the mismatches/ directory.
Comparing resources.arsc (may take a while)...
Package length mismatch: 74824 vs 74699
Files have differences beyond the allowed .res1 differences.
APKs differ on file META-INF/PROTONMA.SF! Files extracted to the mismatches/ directory.
APKs differ on file META-INF/PROTONMA.RSA! Files extracted to the mismatches/ directory.
APKs don't match!

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.

1 participant