Some improvements to apkdiff.

This commit is contained in:
Greyson Parrelli
2026-06-10 13:58:24 -04:00
committed by Cody Henthorne
parent 2e4abd8ed3
commit 204a233235
2 changed files with 19 additions and 6 deletions
+1
View File
@@ -34,6 +34,7 @@ Before you begin, ensure you have the following installed:
- `uv`
- `adb` ([link](https://developer.android.com/tools/adb))
- `bundletool` ([link](https://github.com/google/bundletool/releases))
- `aapt2` (included with the Android SDK Build Tools, [link](https://developer.android.com/tools/aapt2))
You will also need to have Developer Options and USB Debugging enabled on your Android device. You can find instructions to do so [here](https://developer.android.com/studio/debug/dev-options). After the prerequisites are installed and the dev options are enabled, you can connect your Android device to your computer and run the `adb devices` command in your terminal. If everything has been set up correctly, your Android device will show up in the list.
+18 -6
View File
@@ -56,7 +56,19 @@ def compare(apk1, apk2) -> bool:
entry_names = compare_entry_names(zip1, zip2)
entry_contents = compare_entry_contents(zip1, zip2)
resources = compare_resources_arsc(apk1, apk2)
# Some splits (e.g. ABI config splits) contain no resource table. Compare when both APKs have one, treat both
# missing as a match, and fail if only one of them has it.
has_arsc_1 = "resources.arsc" in zip1.namelist()
has_arsc_2 = "resources.arsc" in zip2.namelist()
if has_arsc_1 and has_arsc_2:
resources = compare_resources_arsc(apk1, apk2)
elif has_arsc_1 != has_arsc_2:
print("resources.arsc is present in only one of the APKs!")
resources = False
else:
resources = True
return entry_names and entry_contents and resources
@@ -200,11 +212,11 @@ def compare_resources_arsc(apk1: str, apk2: str) -> bool:
else:
print("resources.arsc files differ!")
diff = difflib.unified_diff(
resources1,
resources2,
fromfile=apk1,
tofile=apk2,
lineterm=''
resources1,
resources2,
fromfile=apk1,
tofile=apk2,
lineterm="",
)
for line in diff:
print(line)