Saturday, February 3, 2018

processor - How to tell what architecture an APK is intended for?


I am writing a script to test a large quantity of apks. Some run on x86 and some run on arm. Is there a way I can tell which apks are intended for which architecture?


I have looked through the report on aapt badging with aapt dump badging application.apk. For some of the arm compatible versions I see native-code: 'armeabi-v7a' but not for all of them, and I don't see any indication of what architecture the x86 compatible apks run on.



I have also tried using apktool to break apart the apk and examine the AndroidManifest.xml. I don't see anything pertaining to the chip architecture in it either.


Any ideas?



Answer



One (rather crude) way to see what architecture an APK's native libraries are built for is to unzip it (it's only a zip file) and take a look at the libs folder - if the application contains any native libraries, they will be split into the following subfolders inside (with the compiled libraries inside these):



See Android Application Package for more information on an APK's structure, and the above list's source. A more complete (including MIPS64) list, along with some information about architecture-specific things, can be found on an archived version of the Android Developer ABI Management page, captured on April 18th 2016.


Interestingly enough, targeting one single ABI (where an app includes native libraries designed for one architecture) doesn't necessarily mean that the app won't run on devices that use other architectures. ARMv8-a, for example, is backwards compatible with ARM and ARMv7-a, and Intel's x86 Android devices contain a proprietary translation layer that allows ARM code to execute on x86 devices (allowing ARM-only apps to run on x86 platforms). A list of the ABIs that an Android device can execute can be found in the ro.product.cpu.abilist property, which can be attained in a shell (e.g. via a terminal app on the device, or over adb using adb shell) using the getprop command: getprop ro.product.cpu.abilist.


No comments:

Post a Comment

samsung galaxy s 2 - Cannot restore Kies backup after firmware upgrade

I backed up my Samsung Galaxy S2 on Kies before updating to Ice Cream Sandwich. After the upgrade I tried to restore, but the restore fails ...