Hi, I was trying to run android sample apps (iotivity/android/examples) with targetSdkVersion 23 and noticed that they all crash at runtime with a UnsatisfiedLinkError.
01-19 10:37:01.780 18276-18561/org.iotivity.base.examples.simpleserver E/AndroidRuntime: FATAL EXCEPTION: Thread-8955 01-19 10:37:01.780 18276-18561/org.iotivity.base.examples.simpleserver E/AndroidRuntime: Process: org.iotivity.base.examples.simpleserver, PID: 18276 01-19 10:37:01.780 18276-18561/org.iotivity.base.examples.simpleserver E/AndroidRuntime: java.lang.UnsatisfiedLinkError: dlopen failed: library "./obj/local/armeabi/liboc.so" not found 01-19 10:37:01.780 18276-18561/org.iotivity.base.examples.simpleserver E/AndroidRuntime: at java.lang.Runtime.loadLibrary(Runtime.java:372) 01-19 10:37:01.780 18276-18561/org.iotivity.base.examples.simpleserver E/AndroidRuntime: at java.lang.System.loadLibrary(System.java:1076) 01-19 10:37:01.780 18276-18561/org.iotivity.base.examples.simpleserver E/AndroidRuntime: at org.iotivity.base.OcPlatform.<clinit>(OcPlatform.java:43) 01-19 10:37:01.780 18276-18561/org.iotivity.base.examples.simpleserver E/AndroidRuntime: at org.iotivity.base.examples.SimpleServer.startSimpleServer(SimpleServer.java:76) 01-19 10:37:01.780 18276-18561/org.iotivity.base.examples.simpleserver E/AndroidRuntime: at org.iotivity.base.examples.SimpleServer.access$000(SimpleServer.java:56) 01-19 10:37:01.780 18276-18561/org.iotivity.base.examples.simpleserver E/AndroidRuntime: at org.iotivity.base.examples.SimpleServer$1$1.run(SimpleServer.java:153) 01-19 10:37:01.780 18276-18561/org.iotivity.base.examples.simpleserver E/AndroidRuntime: at java.lang.Thread.run(Thread.java:818) On running with targetSdkVersion 22, the apps run properly but with the following warnings 01-19 10:38:36.863 19658-19923/org.iotivity.base.examples.simpleserver W/linker: /data/app/org.iotivity.base.examples.simpleserver-1/lib/arm/liboc_logger.so: is missing DT_SONAME will use basename as a replacement: "liboc_logger.so" 01-19 10:38:36.871 19658-19923/org.iotivity.base.examples.simpleserver W/linker: /data/app/org.iotivity.base.examples.simpleserver-1/lib/arm/liboctbstack.so: is missing DT_SONAME will use basename as a replacement: "liboctbstack.so" 01-19 10:38:36.872 19658-19923/org.iotivity.base.examples.simpleserver W/linker: /data/app/org.iotivity.base.examples.simpleserver-1/lib/arm/libconnectivity_abstraction.so: is missing DT_SONAME will use basename as a replacement: "libconnectivity_abstraction.so" 01-19 10:38:36.876 19658-19923/org.iotivity.base.examples.simpleserver W/linker: /data/app/org.iotivity.base.examples.simpleserver-1/lib/arm/liboc.so: is missing DT_SONAME will use basename as a replacement: "liboc.so" 01-19 10:38:36.887 19658-19923/org.iotivity.base.examples.simpleserver W/linker: '/data/app/org.iotivity.base.examples.simpleserver-1/lib/arm/libocstack-jni.so' library has invalid DT_NEEDED entry './obj/local/armeabi/liboc.so' 01-19 10:38:36.887 19658-19923/org.iotivity.base.examples.simpleserver W/linker: '/data/app/org.iotivity.base.examples.simpleserver-1/lib/arm/libocstack-jni.so' library has invalid DT_NEEDED entry './obj/local/armeabi/liboctbstack.so' 01-19 10:38:36.888 19658-19923/org.iotivity.base.examples.simpleserver W/linker: '/data/app/org.iotivity.base.examples.simpleserver-1/lib/arm/libocstack-jni.so' library has invalid DT_NEEDED entry './obj/local/armeabi/liboc_logger.so' 01-19 10:38:36.888 19658-19923/org.iotivity.base.examples.simpleserver W/linker: '/data/app/org.iotivity.base.examples.simpleserver-1/lib/arm/libocstack-jni.so' library has invalid DT_NEEDED entry './obj/local/armeabi/libconnectivity_abstraction.so' 01-19 10:38:36.900 19658-19923/org.iotivity.base.examples.simpleserver I/OIC-JNI: JNI_OnLoad 01-19 10:38:36.901 19658-19923/org.iotivity.base.examples.simpleserver I/art: Thread[14,tid=19923,Native,Thread*=0xaa1b2300,peer=0x12da5160,"Thread-9055"] recursive attempt to load library "/data/app/org.iotivity.base.examples.simpleserver-1/lib/arm/libocstack-jni.so" 01-19 10:38:36.902 19658-19923/org.iotivity.base.examples.simpleserver I/art: Thread[14,tid=19923,Native,Thread*=0xaa1b2300,peer=0x12da5160,"Thread-9055"] recursive attempt to load library "/data/app/org.iotivity.base.examples.simpleserver-1/lib/arm/libocstack-jni.so" 01-19 10:38:36.904 19658-19923/org.iotivity.base.examples.simpleserver W/linker: '/data/app/org.iotivity.base.examples.simpleserver-1/lib/arm/libca-interface.so' library has invalid DT_NEEDED entry './obj/local/armeabi/libconnectivity_abstraction.so' On further analysis, it turned out that all the sharedlibs generated from the iotivity project, which are used by the examples, didn't have a DT_SONAME in them. Android linker until API 22 used basename if the SONAME wasn't available, but from API 23 onwards, has made it necessary to have SONAME while keeping backward compatibility for API versions < 23 https://android.googlesource.com/platform/bionic/+/master/linker/linker.cpp#3683 // Before M release linker was using basename in place of soname. // In the case when dt_soname is absent some apps stop working // because they can't find dt_needed library by soname. // This workaround should keep them working. (applies only // for apps targeting sdk version <=22). Make an exception for // the main executable and linker; they do not need to have dt_soname if (soname_ == nullptr && this != somain && (flags_ & FLAG_LINKER) == 0 && get_application_target_sdk_version() <= 22) { soname_ = basename(realpath_.c_str()); DL_WARN("%s: is missing DT_SONAME will use basename as a replacement: \"%s\"", get_realpath(), soname_); } Ergo, the apps crash at runtime for API 23, unable to find libs although they are present (dlOpen fails). I was able to fix the issue by modifying the build scripts to forcefully add a SONAME to the generated shared libs during build. (-wl, -soname,<lib>) So I wanted to find out if this issue has already been addressed and a fix is available or not. I tried searching online and looking through the docs, but didn't find anything specific related to this and so wasn't sure if I've missed something. Can anyone tell if this is valid or if I've gone wrong somewhere and please correct me. Thanks, Nitheesh -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.iotivity.org/pipermail/iotivity-dev/attachments/20160119/46feea63/attachment.html>
