Ask Your Question

Revision history [back]

dlopen libopencv_java3.so failed using java.lang.System.loadLibrary

i encounter a question that loading libopencv_java3.so failed after i update the android version into N. This open lib can be loaded correctly on android M version. libopencv_java3 is got directly from OpenCV-3.0.0-android-sdk and the followings are the crash log:

06-17 13:56:00.359 E/linker  ( 1938): library "/system/lib/libopencv_java3.so" ("/system/lib/libopencv_java3.so") needed or dlopened by "/system/lib/libnativeloader.so" is not accessible for the namespace: [name="classloader-namespace", ld_library_paths="", default_library_paths="/data/app/com.example.demo-1/lib/arm:/system/fake-libs:/data/app/com.example.demo-1/base.apk!/lib/armeabi-v7a", permitted_paths="/data:/mnt/expand:/data/data/com.example.demo"]

06-17 13:56:00.360 E/HisiPano_HwPanoramaBpbp( 1938): warning: could not load library opencv_java3! 06-17 13:56:00.360 W/System.err( 1938): java.lang.UnsatisfiedLinkError: dlopen failed: library "/system/lib/libopencv_java3.so" needed or dlopened by "/system/lib/libnativeloader.so" is not accessible for the namespace "classloader-namespace" 06-17 13:56:00.361 W/System.err( 1938): at java.lang.Runtime.loadLibrary0(Runtime.java:977) 06-17 13:56:00.361 W/System.err( 1938): at java.lang.System.loadLibrary(System.java:1530)

i check the preview behavior change of Android N, in the "NDK application linked to the platform library" section, it shows the following tips:

Applications should not rely on or use the NDK does not belong to native libraries, because these libraries may change or migrate from one version to another version of Android occur. For example, switching from OpenSSL to BoringSSL That belongs to such changes. In addition, different devices may provide different levels of compatibility, because they do not belong to the NDK library is not in the platform compatibility requirements. If you must access a non-NDK library on older devices, please load based on Android API levels.

To help you diagnose these problems, here are some of Java and NDK errors you may encounter in your attempt to develop applications using the Android N when:

Java Examples of errors:

java.lang.UnsatisfiedLinkError: dlopen failed: library "/system/lib/libcutils.so"
is not accessible for the namespace "classloader-namespace"

dlopen failed:

dlopen failed: can not locate symbol "__system_property_get" referenced by ...

You can use standard JNI function instead of using libandroid_runtime.so getJavaVM and getJNIEnv:

AndroidRuntime :: getJavaVM -> GetJavaVM from <jni.h>
AndroidRuntime :: getJNIEnv -> JavaVM :: GetEnv or 
JavaVM :: AttachCurrentThread from <jni.h>.

You can use the public alternative __system_property_get instead use libcutils.so the property_get symbol. To do so, use the __system_property_get and include the following functions:

#include  <SYS / system_properties.h>

Applications should use the local version instead use libcrypto.so the SSL_ctrl symbol. For example, you should .so statically linked file libcyrpto.a , or include your own dynamic from BoringSSL or OpenSSL in the application libcrypto.so

Does it mean that some corresponding changes need to do in the libopencv_java3.so? if not, what should i do to deal with this problem? and anyone meet the same questions? what's your solution?

waiting for answers and much thanks.

dlopen libopencv_java3.so failed using java.lang.System.loadLibrary

i encounter a question that loading libopencv_java3.so failed after i update the android version into N. This open lib can be loaded correctly on android M version. libopencv_java3 is got directly from OpenCV-3.0.0-android-sdk and the followings are the crash log:

 06-17 13:56:00.359 E/linker  ( 1938): library "/system/lib/libopencv_java3.so" ("/system/lib/libopencv_java3.so") needed or dlopened by "/system/lib/libnativeloader.so" is not accessible for the namespace: [name="classloader-namespace", ld_library_paths="", default_library_paths="/data/app/com.example.demo-1/lib/arm:/system/fake-libs:/data/app/com.example.demo-1/base.apk!/lib/armeabi-v7a", permitted_paths="/data:/mnt/expand:/data/data/com.example.demo"]

06-17 13:56:00.360 E/HisiPano_HwPanoramaBpbp( 1938): warning: could not load library opencv_java3! 06-17 13:56:00.360 W/System.err( 1938): java.lang.UnsatisfiedLinkError: dlopen failed: library "/system/lib/libopencv_java3.so" needed or dlopened by "/system/lib/libnativeloader.so" is not accessible for the namespace "classloader-namespace" 06-17 13:56:00.361 W/System.err( 1938): at java.lang.Runtime.loadLibrary0(Runtime.java:977) 06-17 13:56:00.361 W/System.err( 1938): at java.lang.System.loadLibrary(System.java:1530)

java.lang.System.loadLibrary(System.java:1530)

i check the preview behavior change of Android N, in the "NDK application linked to the platform library" section, it shows the following tips:

Applications should not rely on or use the NDK does not belong to native libraries, because these libraries may change or migrate from one version to another version of Android occur. For example, switching from OpenSSL to BoringSSL That belongs to such changes. In addition, different devices may provide different levels of compatibility, because they do not belong to the NDK library is not in the platform compatibility requirements. If you must access a non-NDK library on older devices, please load based on Android API levels.

To help you diagnose these problems, here are some of Java and NDK errors you may encounter in your attempt to develop applications using the Android N when:

Java Examples of errors:

java.lang.UnsatisfiedLinkError: dlopen failed: library "/system/lib/libcutils.so"
is not accessible for the namespace "classloader-namespace"

dlopen failed:

dlopen failed: can not locate symbol "__system_property_get" referenced by ...

You can use standard JNI function instead of using libandroid_runtime.so getJavaVM and getJNIEnv:

AndroidRuntime :: getJavaVM -> GetJavaVM from <jni.h>
AndroidRuntime :: getJNIEnv -> JavaVM :: GetEnv or 
JavaVM :: AttachCurrentThread from <jni.h>.

You can use the public alternative __system_property_get instead use libcutils.so the property_get symbol. To do so, use the __system_property_get and include the following functions:

#include  <SYS / system_properties.h>

Applications should use the local version instead use libcrypto.so the SSL_ctrl symbol. For example, you should .so statically linked file libcyrpto.a , or include your own dynamic from BoringSSL or OpenSSL in the application libcrypto.so

Does it mean that some corresponding changes need to do in the libopencv_java3.so? if not, what should i do to deal with this problem? and anyone meet the same questions? what's your solution?

waiting for answers and much thanks.