1

please, from Android native; does someone has an idea of how to check if the running app was installed from Android app bundle or directly from APK?

I have an app that allows itself to be shared to others as APK However, when the app was installed from app-bundle, the resulting shared APK can not be run on all devices. therefore, I am trying to make a checkup to determine if the app was installed directly from APK before displaying this specific feature (and remove it if installed from app bundle) I will appreciate any help or weblink or clues. The PackageManager.class seems to not have a method about it.

Toukea Tatsi
  • 139
  • 1
  • 5

2 Answers2

2

maybe try to fetch APK file of target app (like in HERE), unpack it and check resource folder for presence of multiple density buckets or native libs for more than one ABI

snachmsm
  • 10,975
  • 1
  • 22
  • 52
  • Thanks, it is a good clue from my opinion, I can already extract my app APK, now i have to search for a way to fetch APK content (probably as a standard zip file) in order to look for more than one ABI. I think it should work for me! (after a little documentation about APK content and structure) – Toukea Tatsi Nov 24 '20 at 09:54
1

You can check the installerPackageName on the PackageManager to know if the app was installed from the Play Store or sideloaded.

  • Sure, it will work, but i think it will do so only when i will start providing app-bundle on GooglePlay. For now, I am not willing to do so! Thus, until now I am still publishing directly my APK to GooglePlay so that once a user has the app installed, he can keep sharing it around him on regions with internet lack. It is not really what I am locking for, but I think it will work at this specific moment. – Toukea Tatsi Nov 24 '20 at 09:48
  • Yes you have to make sureto block sideloading once you switch to app bundles because if the device doesn't use the same resources folder or achitecture as the one it was downloaded from, it will crash. But you can still distribute APKs on your own and disable the installer check for this variant. – Gregory Nowik Nov 24 '20 at 09:54