3

I created an app that is used for app distribution. It downloads apk files and prompts the user to install them. If I distribute an app with native code only for x86_x64 it won't install on a arm / arm64 device. The package installer says that the app is not compatible with the device.

Is there a way I can determine the compatibility before I prompt the user? Since Api Level 21 I can use Build.SUPPORTED_ABIS to determine what kind of ABIs the device's CPU can handle. But how can I know from the APK if it contains native code?

On my computer I can do it with "aapt d --values badging vlc-arm64.apk" which gives "native-code: 'arm64-v8a'" But I don't have aapt on the Android Device. Is there an equivalent?

shizhen
  • 12,251
  • 9
  • 52
  • 88
Philip Zultan
  • 184
  • 1
  • 8
  • 2
    An APK is just a zip file, so use whatever library you want that can parse zip files to inspect the contents of the APK (e.g. which subfolders, if any, it has under `/lib`). – Michael Jan 24 '18 at 13:15

1 Answers1

1

thanks for the tip, I thought there's maybe a more elegant way. But your suggested solution works. I'm iterating over the zip archive with ZipInputStream and check for all paths that start with lib/xxxx/fileZ and save the xxxx part which is the ABI that is supported by the apk. If the apk doesn't have any included libraries, the apk is supported by every Android device with the minimum sdk.

Philip Zultan
  • 184
  • 1
  • 8