apkeep icon indicating copy to clipboard operation
apkeep copied to clipboard

Split APKs lack base APK

Open asit-fdraschbacher opened this issue 3 years ago • 1 comments

Is it intentional that -d google-play -o split_apk=true only downloads the split APKs and not the base APK (which usually contains the dex code)? IMHO this renders the option unusable, since the downloaded packages cannot be installed and executed.

asit-fdraschbacher avatar Sep 09 '22 10:09 asit-fdraschbacher

In fact, it seems the only way to make apkeep obtain a complete (executable) set of APKs is by running it twice: Once with -o split_apk=true and once with split_apk=false. Unless I'm missing something, the APK obtained with split_apk=false is incomplete as well (it is in fact the base APK of the split APK set, not a multi APK).

asit-fdraschbacher avatar Sep 09 '22 10:09 asit-fdraschbacher

By "base APK" do you mean the original, uploaded package? As I understand it, Google Play does not make this available, since it is in aab format and not suitable for publication.

Hainish avatar Nov 09 '22 02:11 Hainish

When an app (that was submitted as an AAB to Google Play) is downloaded on a device, Google Play servers generate a series of APK files that all need to be installed on the device. For all devices, the series includes the same "base" APK that contains the dex files (compiled Java code). The other "split" APK files depend on the specific device (there's a usually a split for the particular screen density, the particular language, and the processor ISA).

So, the installed app is effectively formed from multiple APK files that all need to be installed on the device, eg:

  • base.apk
  • hdpi.apk
  • armeabi.apk

Your code only either downloads the base apk (base.apk - containing DEX files) or the split files (hdpi.apk, armeabi.apk). Both options are insufficient, as all APK files (base + all splits) are required to form a usable app installation.

It's a shame I cannot link to an official Google documentation here - they have used split APKs and multi APKs in different meanings over time. I recommend inspecting a real device using adb shell pm path com.example.someapp - this will list all APK files that form the installation.

asit-fdraschbacher avatar Nov 14 '22 10:11 asit-fdraschbacher

Thanks for the explainer. Prioritizing this issue.

Hainish avatar Nov 17 '22 00:11 Hainish

I've fixed this in https://github.com/EFForg/rs-google-play/ as of https://github.com/EFForg/rs-google-play/commit/a897c968d77ed78ac824f29bdce15ea239017142.

https://github.com/EFForg/apkeep/commit/aca77e5bed81e14c3a981d85c7440ef0e6455308 fixes this in apkeep.

Hainish avatar Nov 17 '22 01:11 Hainish