1.在项目目录下创建目录libs(不创建也行,一会儿指向对应路径就好),将第三方的jar包放进去。
2.在Android.mk文件中进行配置:
include $(CLEAR_VARS) LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := smartphotolib:../../libs/smartphotolib.jar #前面为自定义的名(umeng_message_push),起什么名都可以,“:”后面的为jar包在项目下对应的路径。 include $(BUILD_MULTI_PREBUILT)
3.引用,在LOCAL_STATIC_JAVA_LIBRARIES中加入smartphotolib 即可
LOCAL_STATIC_JAVA_LIBRARIES := smartphotolib
或
LOCAL_STATIC_JAVA_LIBRARIES += smartphotolib
即可。
1.将so文件复制到libs下面。 2.在Android.mk文件中配置:
include $(CLEAR_VARS) LOCAL_PREBUILT_LIBS := libsmartphotojni:../../libs/arm64-v8a/libsmartphotojni.so include $(BUILD_MULTI_PREBUILT)
3.引用,在Android.mk中添加
LOCAL_JNI_SHARED_LIBRARIES :=libsmartphotojni
即可。
编译会自动将so文件拷贝到out/target/product/***/obj/lib目录下,如果没有拷贝,可以手动拷贝后再进行编译或是写脚本进行拷贝,如下所示:
#so library PRODUCT_COPY_FILES += / ../../libs/arm64-v8a/libsmartphotojni.so:system/lib/libsmartphotojni.so / ../../libs/arm64-v8a/libmxnet_predict.so:system/lib/libmxnet_predict.so
在APK的Android.mk添加第三方AAR 创建libs/aaa.arr文件,修改Android.mk如下
... LOCAL_AAPT_FLAGS+= --auto-add-overlay / --extra-packages aaa LOCAL_STATIC_JAVA_AAR_LIBRARIES:=aaa ... include $(CLEAR_VARS) LOCAL_MODULE_TAGS:=optional LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES:=aaa:libs/aaa.aar include $(BUILD_MULTI_PREBUILT)
1.在jni文件夹下面新建prebuilt文件夹,把需要拷贝的so放倒该文件夹下面。在Android.mk中加入以下代码
#################################################################此处为App必需导入的玩外部so文件 include $(CLEAR_VARS) LOCAL_MODULE := BaiduMapSDK_base_v4_4_0 LOCAL_SRC_FILES := prebuilt/libBaiduMapSDK_base_v4_4_0.so include $(PREBUILT_SHARED_LIBRARY) #LOCAL_SHARED_LIBRARIES := BaiduMapSDK_base_v4_4_0 include $(CLEAR_VARS) LOCAL_MODULE := locSDK7a LOCAL_SRC_FILES := prebuilt/liblocSDK7a.so include $(PREBUILT_SHARED_LIBRARY) #LOCAL_SHARED_LIBRARIES := locSDK7a #################################################################