android jni项目会删除第三方so文件的问题解决(jni project delete third-party .so file)

安卓项目开发中,项目中使用到jni开发,使用C/C++编写了自己的so库,调试和运行一切正常,Android.mk文件代码如下:

 

include $(CLEAR_VARS)

#opencv
OPENCV_CAMERA_MODULES:=on
OPENCV_INSTALL_MODULES:=on
OPENCV_LIB_TYPE:=SHARED
include ${OPENCVROOT}/sdk/native/jni/OpenCV.mk

LOCAL_LDLIBS += -llog
LOCAL_MODULE := xface
LOCAL_SRC_FILES := xface.cpp

 

如果我们需要引入其他第三方so库到libs/armeabi中时,在项目编译运行的时候会发现,刚刚加入的第三方so库,被删除了。

 

1、在jni中新建目录“prebuilt”
2、修改Android.mk文件,把我们的第三方so库加入进去,在我上面Android.mk增加后的内容如下:

include $(CLEAR_VARS)
LOCAL_MODULE := tpnsWatchdog
LOCAL_SRC_FILES := prebuilt/libmsc.so
include $(PREBUILT_SHARED_LIBRARY)

include $(CLEAR_VARS)

#opencv
OPENCV_CAMERA_MODULES:=on
OPENCV_INSTALL_MODULES:=on
OPENCV_LIB_TYPE:=SHARED
include ${OPENCVROOT}/sdk/native/jni/OpenCV.mk

LOCAL_LDLIBS += -llog
LOCAL_MODULE := xface
LOCAL_SRC_FILES := xface.cpp