package manager service是怎样选择armeabi/armeabi-v7a中的库文件的?


APP_ABI := armeabi armeabi-v7a


in armeabi/:,,, in armeabi-v7a/:,,,,

需要注意这一点:The 'armeabi-v7a' machine code will not run on ARMv5 or ARMv6 based devices. 如果损失一些应用的性能是可以接受的,不希望保留库的两份拷贝,可以移除armeabi-v7a目录和其下的库文件,只保留armeabi目录。在安装应用时,行为是这样的,

When installing an application, the package manager service will scan the .apk and look for any shared library of the form:


If one is found, then it is copied under $APPDIR/lib/, where $APPDIR corresponds to the application's specific data directory. If none is found, and a secondary ABI is defined, the service will then scan for shared libraries of the form:


If anything is found, then it is copied under $APPDIR/lib/

什么是primary abi和secondary abi呢,

The Android system knows at runtime which ABI(s) it supports. More precisely, up to two build-specific system properties are used to indicate: the 'primary' ABI for the device, corresponding to the machine code used in the system image itself. an optional 'secondary' ABI, corresponding to another ABI that is also supported by the system image. For example, a typical ARMv5TE-based device would only define the primary ABI as 'armeabi' and not define a secondary one. On the other hand, a typical ARMv7-based device would define the primary ABI to 'armeabi-v7a' and the secondary one to 'armeabi' since it can run application native binaries generated for both of them. This mechanism ensures that the best machine code for the target device is automatically extracted from the package at installation time.


in armeabi/:,,, in armeabi-v7a/:,

如此,安装运行在v7a的设备上,会发生什么? 尝试了一些手机和平板,CPU都是ARMv7的,Android都是4.x的。行为是拷贝以下库文件到$APPDIR/lib/目录下,

armeabi-v7a/, armeabi-v7a/, armeabi/, armeabi/, armeabi/

符合特殊需求,libd对性能影响较大,针对ARMv7设备,使用armeabi-v7a的库,其他都使用armeabi的库。 但是遇到在一台ARMv7+Android2.3.4的手机上,加载libp.so报错。 再尝试另一台ARMv7+Android2.3.5的手机,一样的现象。 针对这两台手机,如果打包apk时移除armeabi-v7a目录,不会报错。 难道Android2.3的设备,package manager service的行为有异?

posted on 2013-04-25 17:11  LoveIsBug  阅读(...)  评论(...编辑  收藏