[RK3399][Android7.1] 调试笔记 --- JNI无法访问so提示not accessible

Platform: RK3399
OS: Android 7.1
Kernel: v4.4.83

背景:
之前在rk3288平台上测试的串口程序,到rk3399无法使用了,提示
library "/system/lib64/libserialport.so" ("/system/lib64/libserialport.so") needed or dlopened by"/system/lib64/libnativeloader.so" is not accessible for the namespace "classloader-namespace"


具体Log:

09-10 18:33:37.549 1549-1549/com.example.serialport E/linker: library "/system/lib64/libserialport.so" ("/system/lib64/libserialport.so") needed or dlopened by "/system/lib64/libnativeloader.so" is not accessible for the namespace: [name="classloader-namespace", ld_library_paths="", default_library_paths="", permitted_paths="/data:/mnt/expand:/data/data/com.example.serialport"]
09-10 18:33:37.550 1549-1549/com.example.serialport D/AndroidRuntime: Shutting down VM
09-10 18:33:37.551 1549-1549/com.example.serialport E/AndroidRuntime: FATAL EXCEPTION: main
                                                                      Process: com.example.serialport, PID: 1549
                                                                      java.lang.UnsatisfiedLinkError: dlopen failed: library "/system/lib64/libserialport.so" needed or dlopened by "/system/lib64/libnativeloader.so" is not accessible for the namespace "classloader-namespace"
                                                                          at java.lang.Runtime.loadLibrary0(Runtime.java:989)
                                                                          at java.lang.System.loadLibrary(System.java:1562)
                                                                          at com.example.serialport.SerialPort.(SerialPort.java:141)
                                                                          at com.example.serialport.ExternalDevices.(ExternalDevices.java:19)
                                                                          at com.example.serialport.DroidRobot.Init(DroidRobot.java:13)
                                                                          at com.example.serialport.MainActivity.onCreate(MainActivity.java:25)
                                                                          at android.app.Activity.performCreate(Activity.java:6709)
                                                                          at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
                                                                          at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2619)
                                                                          at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2727)
                                                                          at android.app.ActivityThread.-wrap12(ActivityThread.java)
                                                                          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1478)
                                                                          at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                          at android.os.Looper.loop(Looper.java:154)
                                                                          at android.app.ActivityThread.main(ActivityThread.java:6121)
                                                                          at java.lang.reflect.Method.invoke(Native Method)
                                                                          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:912)
                                                                          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:802)
09-10 18:33:37.581 1549-1549/com.example.serialport I/Process: Sending signal. PID: 1549 SIG: 9

解决方法:
修改system/core/rootdir/etc/public.libraries.android.txt
添加你要使用的的so到此问题件中。

kris@eco:~$ cat public.libraries.txt 
....
libwebviewchromium_plat_support.so
libz.so
libserialport.so

也可以直接不编译在板子上修改,对应目录/system/etc


参考:
Framework基础:Android N 公共so库怎么定义呢?
[Google]原生库的命名空间

你可能感兴趣的:(RK3399,子类__Android)