Linking native Libraries in Android App


ABI

ABI, shorts for Application Binary Interface, is a concept combine the ARM architecture and Instructure set by some formal definition. According to the official document, android support 7 kinds of ABIs, if we want our app to support more android devices, we should package all 7 kinds of ABIs binaries to the package, in this case, it is a linking library.

The advantage of this full package is that it can compatible with more devices, the disadvantage is that it enlarged the package size. Also in some situation, the linking library is provided by the third party, missing some ABI types. Then we should use the custom way to implement this app.

How get current device's ABI?

# ro.product.cpu.abi and ro.product.cpu.abi2 are obsolete,
# use ro.product.cpu.abilist instead.
ro.product.cpu.abi=armeabi-v7a
ro.product.cpu.abi2=armeabi
ro.product.cpu.abilist=armeabi-v7a,armeabi
ro.product.cpu.abilist32=armeabi-v7a,armeabi
ro.product.cpu.abilist64=

java.lang.UnsatisfiedLinkError

I met this Error recently, in short, the app can not found its native libraries, that's weird, so I researched the mechanism of how Android app import and load its native library. I guess the secret is hidden behind the above system readable properties, during the installation process, the system extracts the needed ABI library from the APK package. The Unsatisfied Link Error appears when the APK didn't prepare the needed ABI binary library.


Comments

Popular posts from this blog

Bluedroid stack in android

How to setup a NAT server?

Network programming in elisp