android第三方apk整合系統apk,Android.mk編寫
最近做專案,遇到含有so庫的第三方apk要把他整合到系統裡,程式碼如下:
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := touying
LOCAL_MODULE_TAGS := optional
LOCAL_STATIC_LIBRARIES:= libAndroidTouchScreen \
libdepthColorOutput \
libOpenCV \
libopencv_java3 \
libOpenNI.jni \
libOpenNI \
libOrbbecTouchEngine \
liborbbecusb \
libOrbbecUtils \
libOrbbecUtils_jni \
libXnCore \
libXnDDK \
libXnDeviceFile \
libXnDeviceSensorV2 \
libXnFormats
LOCAL_MODULE_PATH := $(TARGET_OUT)/app
LOCAL_SRC_FILES := touying.apk
LOCAL_MODULE_CLASS := APPS
LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
LOCAL_PROGUARD_FLAG_FILES := proguard.flags
LOCAL_CERTIFICATE := platform
include $(BUILD_PREBUILT)
需把apk解壓將so庫取出
include $(CLEAR_VARS)
LOCAL_PREBUILT_LIBS:=libAndroidTouchScreen:lib/armeabi-v7a/libAndroidTouchScreen.so \
libdepthColorOutput:lib/armeabi-v7a/libdepthColorOutput.so \
libOpenCV:lib/armeabi-v7a/libOpenCV.so \
libopencv_java3:lib/armeabi-v7a/libopencv_java3.so \
libOpenNI.jni:lib/armeabi-v7a/libOpenNI.jni.so \
libOpenNI:lib/armeabi-v7a/libOpenNI.so \
libOrbbecTouchEngine:lib/armeabi-v7a/libOrbbecTouchEngine.so \
liborbbecusb:lib/armeabi-v7a/liborbbecusb.so \
libOrbbecUtils:lib/armeabi-v7a/libOrbbecUtils.so \
libOrbbecUtils_jni:lib/armeabi-v7a/libOrbbecUtils_jni.so \
libXnCore:lib/armeabi-v7a/libXnCore.so \
libXnDDK:lib/armeabi-v7a/libXnDDK.so \
libXnDeviceFile:lib/armeabi-v7a/libXnDeviceFile.so \
libXnDeviceSensorV2:lib/armeabi-v7a/libXnDeviceSensorV2.so \
libXnFormats:lib/armeabi-v7a/libXnFormats.so
include $(BUILD_MULTI_PREBUILT)
因為本身第三方apk內就含有so庫,但是把他放到system/app下燒錄提示錯誤說system/lib下找不到對應so包,所以 include $(BUILD_MULTI_PREBUILT)程式碼意思就是把那些so檔案copy到system/lib下。
完成後必須先mmm,如果直接編譯全部檔案還是會copy不到system/lib下。
如果有知道更好方法的歡迎留言