Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to determine if an APK is compatible with device supported ABIs?

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?

like image 934
Philip Zultan Avatar asked Sep 15 '25 10:09

Philip Zultan


1 Answers

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.

like image 128
Philip Zultan Avatar answered Sep 18 '25 12:09

Philip Zultan