MuntashirAkon / AppManager

A full-featured package manager and viewer for Android
https://muntashirakon.github.io/AppManager/
Other
5.04k stars 282 forks source link

Cannot properly handle duplicate APKs generated by bundletool #1021

Open MuntashirAkon opened 1 year ago

MuntashirAkon commented 1 year ago

Please check before submitting an issue

Describe the bug

If an app has native libraries, depending on how they are used and target SDK, they are stored compressed or uncompressed. In case of uncompressed, the libraries are memory mapped, therefore, there's no reason for it to be extracted. The logic for this in bundletool is described here:

https://github.com/google/bundletool/blob/da6938b27645db6488261610d2298c65ca9ba44f/src/main/java/com/android/tools/build/bundletool/splitters/NativeLibsCompressionVariantGenerator.java#LL49C5-L59C7

If the persistent app is installable on external storage only split APKs targeting device above Android P should be uncompressed (as uncompressed native libraries crashes with ASEC external storage and support for ASEC external storage is removed in Android P).

If persistent app is not installable on external storage but has native activities, native libraries should be uncompressed on Android N+ only as will crash uncompressed on Android M.

Finally if persistent app is not installable on external storage and doesn't have native activities, only the split APKs targeting devices above Android M should be uncompressed.

Now, if one of the above criteria is matched, bundletool will generate duplicate APK files in order to account for compressed and uncompressed native libraries (e.g. one APK with extractNativeLibs set to true and other with false in the ApplicationManifest.xml).

App Manager, as of v3.1.0, will cause a crash if it find more than one APK files by the same name because it cannot handle duplicate base APK files.

To Reproduce

No response

Expected behavior

App Manager should, as done by bundletool, scan all entries to match the best base APK files with reasons included for this specific cases. (App Manager has already done quite well in selecting the correct splits in other cases.)

Screenshots

No response

Logs

No response

Device info

Additional context

No response

MuntashirAkon commented 1 year ago

Related issue: https://github.com/Aefyr/SAI/issues/162