Error UnsatisfiedLinkError: dlopen failed: library while trying to create a JNI Service

huangapple go评论79阅读模式
英文:

Error UnsatisfiedLinkError: dlopen failed: library while trying to create a JNI Service

问题

以下是要翻译的内容:

我正在尝试创建一个访问JNI共享库的服务,但当它尝试访问该库时,它返回一个异常。

8746 05-29 05:00:16.259 921 921 E AndroidRuntime: FATAL EXCEPTION: main
8747 05-29 05:00:16.259 921 921 E AndroidRuntime: Process: vendor.alvenan.javanativetestservice,PID:921
8748 05-29 05:00:16.259 921 921 E AndroidRuntime: java.lang.UnsatisfiedLinkError:dlopen失败:找不到库"libjavanativetestservice_jni.so"
8749 05-29 05:00:16.259 921 921 E AndroidRuntime: 在java.lang.Runtime.loadLibrary0(Runtime.java:1077)处
8750 05-29 05:00:16.259 921 921 E AndroidRuntime: 在java.lang.Runtime.loadLibrary0(Runtime.java:998)处
8751 05-29 05:00:16.259 921 921 E AndroidRuntime: 在java.lang.System.loadLibrary(System.java:1661)处
8752 05-29 05:00:16.259 921 921 E AndroidRuntime: 在vendor.alvenan.javanativetestservice.JavaNativeTestServiceImpl.(JavaNativeTestServiceImpl.java:14)处
8753 05-29 05:00:16.259 921 921 E AndroidRuntime: 在vendor.alvenan.javanativetestservice.JavaNativeTestService.onCreate(JavaNativeTestService.java:14)处
8754 05-29 05:00:16.259 921 921 E AndroidRuntime: 在android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1277)处
8755 05-29 05:00:16.259 921 921 E AndroidRuntime: 在android.app.ActivityThread.handleBindApplication(ActivityThread.java:6759)处
8756 05-29 05:00:16.259 921 921 E AndroidRuntime: 在android.app.ActivityThread.-$$Nest$mhandleBindApplication(Unknown Source:0)处
8757 05-29 05:00:16.259 921 921 E AndroidRuntime: 在android.app.ActivityThread$H.handleMessage(ActivityThread.java:2133)处
8758 05-29 05:00:16.259 921 921 E AndroidRuntime: 在android.os.Handler.dispatchMessage(Handler.java:106)处
8759 05-29 05:00:16.259 921 921 E AndroidRuntime: 在android.os.Looper.loopOnce(Looper.java:201)处
8760 05-29 05:00:16.259 921 921 E AndroidRuntime: 在android.os.Looper.loop(Looper.java:288)处
8761 05-29 05:00:16.259 921 921 E AndroidRuntime: 在android.app.ActivityThread.main(ActivityThread.java:7872)处
8762 05-29 05:00:16.259 921 921 E AndroidRuntime: 在java.lang.reflect.Method.invoke(Native Method)处
8763 05-29 05:00:16.259 921 921 E AndroidRuntime: 在com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)处

我正在使用ARPI13项目:
https://github.com/snappautomotive/firmware_rpi-local_manifests/tree/arpi-13

JNI库似乎放在了正确的位置:

rpi4:/ # cat vendor/etc/public.libraries.txt
libjavanativetestservice_jni.so
rpi4:/ # ls -l vendor/lib64/libjavanativetestservice_jni.so
-rw-r--r-- 1 root root 10952 2023-05-29 15:40 vendor/lib64/libjavanativetestservice_jni.so

完整的代码在GitHub上:https://github.com/alvenan/aosp_bench/tree/main/bench_test_jni

设备的makefile设置如下:

PRODUCT_PACKAGES += JavaNativeTestService
PRODUCT_COPY_FILES +=
vendor/alvenan/aosp_bench/bench_test_jni/public.libraries.txt:$(TARGET_COPY_OUT_VENDOR)/etc/public.libraries.txt

英文:

I am trying create a Service that access a JNI shared library, but when it tries to access the lib it returns an exception.

 8746 05-29 05:00:16.259   921   921 E AndroidRuntime: FATAL EXCEPTION: main                                                                                                  │
 8747 05-29 05:00:16.259   921   921 E AndroidRuntime: Process: vendor.alvenan.javanativetestservice, PID: 921                                                                │
 8748 05-29 05:00:16.259   921   921 E AndroidRuntime: java.lang.UnsatisfiedLinkError: dlopen failed: library "libjavanativetestservice_jni.so" not found                     │
 8749 05-29 05:00:16.259   921   921 E AndroidRuntime:    at java.lang.Runtime.loadLibrary0(Runtime.java:1077)                                                                │
 8750 05-29 05:00:16.259   921   921 E AndroidRuntime:    at java.lang.Runtime.loadLibrary0(Runtime.java:998)                                                                 │
 8751 05-29 05:00:16.259   921   921 E AndroidRuntime:    at java.lang.System.loadLibrary(System.java:1661)                                                                   │
 8752 05-29 05:00:16.259   921   921 E AndroidRuntime:    at vendor.alvenan.javanativetestservice.JavaNativeTestServiceImpl.<clinit>(JavaNativeTestServiceImpl.java:14)       │
 8753 05-29 05:00:16.259   921   921 E AndroidRuntime:    at vendor.alvenan.javanativetestservice.JavaNativeTestService.onCreate(JavaNativeTestService.java:14)               │
 8754 05-29 05:00:16.259   921   921 E AndroidRuntime:    at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1277)                                   │
 8755 05-29 05:00:16.259   921   921 E AndroidRuntime:    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6759)                                       │
 8756 05-29 05:00:16.259   921   921 E AndroidRuntime:    at android.app.ActivityThread.-$$Nest$mhandleBindApplication(Unknown Source:0)                                      │
 8757 05-29 05:00:16.259   921   921 E AndroidRuntime:    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2133)                                             │
 8758 05-29 05:00:16.259   921   921 E AndroidRuntime:    at android.os.Handler.dispatchMessage(Handler.java:106)                                                             │
 8759 05-29 05:00:16.259   921   921 E AndroidRuntime:    at android.os.Looper.loopOnce(Looper.java:201)                                                                      │
 8760 05-29 05:00:16.259   921   921 E AndroidRuntime:    at android.os.Looper.loop(Looper.java:288)
 8761 05-29 05:00:16.259   921   921 E AndroidRuntime:    at android.app.ActivityThread.main(ActivityThread.java:7872)
 8762 05-29 05:00:16.259   921   921 E AndroidRuntime:    at java.lang.reflect.Method.invoke(Native Method)
 8763 05-29 05:00:16.259   921   921 E AndroidRuntime:    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)

I am using the ARPI13 project:
https://github.com/snappautomotive/firmware_rpi-local_manifests/tree/arpi-13

The JNI lib seems to be in the right place:

rpi4:/ # cat vendor/etc/public.libraries.txt
libjavanativetestservice_jni.so
rpi4:/ # ls -l vendor/lib64/libjavanativetestservice_jni.so
-rw-r--r-- 1 root root 10952 2023-05-29 15:40 vendor/lib64/libjavanativetestservice_jni.so

The full code is on github: https://github.com/alvenan/aosp_bench/tree/main/bench_test_jni

The device makefile has the following setup:

PRODUCT_PACKAGES += JavaNativeTestService
PRODUCT_COPY_FILES += \
   vendor/alvenan/aosp_bench/bench_test_jni/public.libraries.txt:$(TARGET_COPY_OUT_VENDOR)/etc/public.libraries.txt

答案1

得分: 0

从共享库 Android.bp 中移除 vendor: true 标签解决了问题。

英文:

Removing vendor: true tag from the shared lib Android.bp fixed the problem

huangapple
  • 本文由 发表于 2023年5月30日 02:37:11
  • 转载请务必保留本文链接:https://go.coder-hub.com/76359654.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定