How to tell what architecture an APK is intended for?


Question

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.


I'm looking for something on a linux platform.


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.


Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes