预制包含很多lib库的apk

1. Androidmk写法

预编译时使用LOCAL_PREBUILT_JNI_LIBS,来制定库的路径

LOCAL_PATH := $(call my-dir)


define get-all-libraries-module-name-in-subdirs
$(sort $(shell cd $(LOCAL_PATH) ; find -L $(1) -name "*.so"))
endef


ALL_LIBRARIES_MODULE_NAME := $(call get-all-libraries-module-name-in-subdirs, lib/arm64-v8a)

$(warning ALL_LIBRARIES_MODULE_NAME:---  $(ALL_LIBRARIES_MODULE_NAME) )

#integrate the apk
include $(CLEAR_VARS)
LOCAL_MODULE        := BinderTest
LOCAL_MODULE_TAGS   := optional
LOCAL_MODULE_CLASS  := APPS
LOCAL_CERTIFICATE   := PRESIGNED
LOCAL_MODULE_SUFFIX := .apk
LOCAL_SRC_FILES     := ./BinderTest.apk
LOCAL_MULTILIB := 64
LOCAL_MODULE_PATH   := $(TARGET_OUT_SYSTEM_APPS)
LOCAL_PREBUILT_JNI_LIBS := $(ALL_LIBRARIES_MODULE_NAME)
include $(BUILD_PREBUILT)

2. 编译结果

编译log看,只是把库拷贝到system/app/BinderTest/lib下面,并没有预制到system/lib64,这才是正确的预制方法

[ 82% 51/62] Copy: out/target/product/msm8996_gvmq/system/app/BinderTest/lib/arm64/libplug_ins_project.so
[ 83% 52/62] Copy: out/target/product/msm8996_gvmq/system/app/BinderTest/lib/arm64/libdumpcrash.so
[ 83% 52/62] Copy: out/target/product/msm8996_gvmq/system/app/BinderTest/lib/arm64/libsync_cxx.so
[ 85% 53/62] Copy: out/target/product/msm8996_gvmq/system/app/BinderTest/lib/arm64/libifly_aime.so
[ 85% 53/62] Copy: out/target/product/msm8996_gvmq/system/app/BinderTest/lib/arm64/libtbt.so
[ 87% 54/62] Copy: out/target/product/msm8996_gvmq/system/app/BinderTest/lib/arm64/libGNaviDice.so
[ 88% 55/62] Copy: out/target/product/msm8996_gvmq/system/app/BinderTest/lib/arm64/liblinkProxy-1.0.0.so
[ 90% 56/62] Copy: out/target/product/msm8996_gvmq/system/app/BinderTest/lib/arm64/libplug_ins_project.so
[ 91% 57/62] Copy: out/target/product/msm8996_gvmq/system/app/BinderTest/lib/arm64/libmqtt_jni.so
[ 93% 58/62] Copy: out/target/product/msm8996_gvmq/system/app/BinderTest/lib/arm64/libsync_cxx.so
[ 95% 59/62] Copy: out/target/product/msm8996_gvmq/system/app/BinderTest/lib/arm64/libisstts.so
[ 96% 60/62] Copy: out/target/product/msm8996_gvmq/system/app/BinderTest/lib/arm64/libhsl.so
[ 98% 61/62] Copy: out/target/product/msm8996_gvmq/system/app/BinderTest/lib/arm64/libtbt.so
[ 98% 61/62] Install: out/target/product/msm8996_gvmq/system/app/BinderTest/BinderTest.apk
[100% 62/62] Install: out/target/product/msm8996_gvmq/system/app/BinderTest/BinderTest.apk

out目录看,apk拷贝到了app/lib下面,这样apk就是用这个位置的库

android/out/target/product/msm8996_gvmq/system/app/BinderTest ls
BinderTest.apk  lib  oat

ubuntu@ubuntu:/android/out/target/product/msm8996_gvmq/system/app/BinderTest/lib/arm64$ ll
-rwxrwxr-x 1 ubuntu ubuntu  1738664 11月 15 17:10 libxxx.so*
-rwxrwxr-x 1 ubuntu ubuntu  1354248 11月 15 17:10 libxxxxxx.so*
-rwxrwxr-x 1 ubuntu ubuntu  1243400 11月 15 17:10 libaime_key_gd.so*
-rwxrwxr-x 1 ubuntu ubuntu    59720 11月 15 17:10 libapssdk.so*

3. LOCAL_PREBUILT_JNI_LIBS原理

LOCAL_PREBUILT_JNI_LIBS := \
            lib/armeabi/libcom_iflytek_inputmethod_bundlesetting.so \
            lib/armeabi/libcom_iflytek_inputmethod_mmp.so \

原理就是调用copy-one-file,把LOCAL_PREBUILT_JNI_LIBS的值循环拷贝到app/lib下面

@build/core/install_jni_libs.mk
my_prebuilt_jni_libs := $(LOCAL_PREBUILT_JNI_LIBS)

@build/core/install_jni_libs_internal.mk
# Install my_prebuilt_jni_libs as separate files.
$(foreach lib, $(my_prebuilt_jni_libs), \
    $(eval $(call copy-one-file, $(lib), $(my_app_lib_path)/$(notdir $(lib)))))

  • 8
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值