欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

Android编译mk文件引入三方jar、aar、so

程序员文章站 2022-03-10 15:24:02
引入aar:LOCAL_STATIC_JAVA_AAR_LIBRARIES := okayrom-lib-http-1.1.0.9 \引入jar:#当前模块依赖的 Java 静态库 为引用jar库的别名,可以随便取名,一般就是用库名称就可以了。LOCAL_STATIC_JAVA_LIBRARIES := haha \##############################################include $(CLEAR_VARS)#作为预编译库的引用对象 指定p.....

引入aar:

LOCAL_STATIC_JAVA_AAR_LIBRARIES := okayrom-lib-http-1.1.0.9 \

引入jar:

#当前模块依赖的 Java 静态库 为引用jar库的别名,可以随便取名,一般就是用库名称就可以了。
LOCAL_STATIC_JAVA_LIBRARIES := haha \ 

##############################################
include $(CLEAR_VARS)

#作为预编译库的引用对象  指定prebuilt java库规则,格式为:别名:jar文件的完整路径,这里的别名就是LOCAL_STATIC_JAVA_LIBRARIES所取的名字。
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES :=  haha:libs/haha.jar \                                   
                                       http-1.1.0.9:libs/http-1.1.0.9.aar \                                      

#BUILD_MULTI_PREBUILT 生成对象作为预编译库。

include $(BUILD_MULTI_PREBUILT)

 

引入三方so:

include $(CLEAR_VARS)

LOCAL_MODULE := libtensorflowlite_jni
LOCAL_SRC_FILES := libs/libtensorflowlite_jni.so
include $(PREBUILT_SHARED_LIBRARY)

 

需要注意的是引入so需要刷一下system.img,处理报错:

12-05 10:15:54.108  2074  2074 E linker  : library "/system/lib64/libtensorflowlite_jni.so" ("/system/lib64/libtensorflowlite_jni.so") needed or dlopened by "/system/lib64/libnativeloader.so" is not accessible for the namespace: [name="classloader-namespace", ld_library_paths="", default_library_paths="/data/app/com.android.settings-2/base.apk!/lib/arm64-v8a", permitted_paths="/data:/mnt/expand:/data/data/com.android.settings"]
12-05 10:15:54.111  2074  2074 E linker  : library "/system/lib64/libtensorflowlite_jni.so" ("/system/lib64/libtensorflowlite_jni.so") needed or dlopened by "/system/lib64/libnativeloader.so" is not accessible for the namespace: [name="classloader-namespace", ld_library_paths="", default_library_paths="/data/app/com.android.settings-2/base.apk!/lib/arm64-v8a", permitted_paths="/data:/mnt/expand:/data/data/com.android.settings"]
12-05 10:15:54.112  2074  2074 E art     : No implementation found for long org.tensorflow.lite.NativeInterpreterWrapper.createErrorReporter(int) (tried Java_org_tensorflow_lite_NativeInterpreterWrapper_createErrorReporter and Java_org_tensorflow_lite_NativeInterpreterWrapper_createErrorReporter__I)
--------- beginning of crash
12-05 10:15:54.114  2074  2074 E AndroidRuntime: FATAL EXCEPTION: main
12-05 10:15:54.114  2074  2074 E AndroidRuntime: Process: com.android.settings, PID: 2074
12-05 10:15:54.114  2074  2074 E AndroidRuntime: java.lang.UnsatisfiedLinkError: No implementation found for long org.tensorflow.lite.NativeInterpreterWrapper.createErrorReporter(int) (tried Java_org_tensorflow_lite_NativeInterpreterWrapper_createErrorReporter and Java_org_tensorflow_lite_NativeInterpreterWrapper_createErrorReporter__I)
12-05 10:15:54.114  2074  2074 E AndroidRuntime:     at org.tensorflow.lite.NativeInterpreterWrapper.createErrorReporter(Native Method)
12-05 10:15:54.114  2074  2074 E AndroidRuntime:     at org.tensorflow.lite.NativeInterpreterWrapper.<init>(NativeInterpreterWrapper.java:59)
12-05 10:15:54.114  2074  2074 E AndroidRuntime:     at org.tensorflow.lite.Interpreter.<init>(Interpreter.java:223)
 

解决方案:

1.刷编译成功后刷system.img

2.在/system/etc/public.libraries.txt中添加so,先pull出来,修改完push一下重启即可。

 

本文地址:https://blog.csdn.net/hello_java_Android/article/details/110678604

相关标签: Android jar