Android源码集成第三方jar和so库

Android源码中MyAPIs放在packages/apps下。MyAPIs下创建目录libs以及libs/armeabi,并把MyJar.jar放在libs/,把libMyLib.so放在libs/armeabi。

LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES:=libMyJar:libs/MyJar.jar
LOCAL_PREBUILT_LIBS:=libMyLib:libs/armeabi/libMyLib.so

include $(BUILD_MULTI_PREBUILT) 

1、集成jar包
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES指定prebuiltjar库的规则,格式:别名:jar文件路径,编译用BUILD_MULTI_PREBUILT

注:别名要跟jar包名字一致
如上,jar包名为MyJar,则别名为libMyJar

2、集成.so包
LOCAL_PREBUILT_LIBS指定prebuilt so的规则,格式:别名:so文件路径
别名的命名同上,编译用BUILD_MULTI_PREBUILT

3、MyAPIs.apk编译生成在out/target/product//system/app/下;

libMyLib.so放在out/target/product//system/lib/下,这也是系统加载动态库时搜索的路径。

4、如果.so需要编译,则先用LOCAL_JNI_SHARED_LIBRARIES指定,然后再用LOCAL_MODULE_INCLUDE_LIBRARY := true打包so到apk

5、64和32系统选择不同的库
ifeq (arm64, (strip ( s t r i p (TARGET_ARCH)))
LOCAL_PREBUILT_LIBS := libssl:libs/arm64-v8a/libssl.so
LOCAL_PREBUILT_LIBS += libcrypto:libs/arm64-v8a/libcrypto.so
LOCAL_PREBUILT_LIBS += libvivosgmain:libs/arm64-v8a/libaa.so
else
LOCAL_PREBUILT_LIBS := libssl:libs/armeabi-v7a/libssl.so
LOCAL_PREBUILT_LIBS += libcrypto:libs/armeabi-v7a/libcrypto.so
LOCAL_PREBUILT_LIBS += libvivosgmain:libs/armeabi-v7a/libtest.so
endif
LOCAL_MULTILIB := both 32和64都编译。

你可能感兴趣的:(Android源码集成第三方jar和so库)