3

I have developed android project using android studio. It uses android native library which other developer built for speech recognization. The APK works perfectly when i install on android devices.

I need to put this APK into AOSP because I am going to make android device only for our system. (I have already customized AOSP) But after adding the APK into AOSP, the APK can not load library.

Error log:

 java.lang.UnsatisfiedLinkError: dlopen failed: can't protect segments for "../libsengine.so": Permission denied

Please help me to fix this problem.

Zoe
  • 27,060
  • 21
  • 118
  • 148
Yuichi Akiyoshi
  • 409
  • 5
  • 19
  • The `../` isn't a good sign to me. How do you load **libsengine**? From Java? From another shared library with **dlopen()**? Or it is loaded as a NEEDED dependency of another shared library? – Alex Cohn Dec 28 '17 at 17:53
  • I am calling System.loadLibrary("libsengine") in Java. It works if i install apk on android devices. – Yuichi Akiyoshi Dec 29 '17 at 01:33
  • Please provide your build.gradle and post a screenshot or write down where in your project structure you already tried to put the extracted libsengine.so file. – Yuliwee Dec 30 '17 at 10:06
  • When it coming, whether while build or runtime? – sandeepmaaram Dec 30 '17 at 16:40

3 Answers3

3

If you add your apk into AOSP system/app/ path as a prebuilt app, this might be of help: Error adding prebuilt apk with shared libraries to AOSP http://blog.csdn.net/a462533587/article/details/46380795 The problem is the shared library packaged in your apk has never been extracted to /data/app-lib directory, so it can't be linked.

R.h
  • 60
  • 8
3

It seems that the library you are using is utilizing some sort of dynamic code loading that is strictly prohibided on Android 26+ (Writable and Executable Segments Enforced for API level >= 26) . You can read more about the security risk of TEXTREL on the following blog.

I assume that the reason the code works when compiling with Android Studio is because your build.gradle defines a minSdkVersion/targetSdkVersion that does not enforce the TEXTREL check. When compiling via the AOSP make, targetSdkVersion is most probably defined to be the 'current' version where the TEXTREL check is enforced.

These are only assumptions, so I guess you could check or alternatively provide more information such as the platform you are building and the Android.mk + build.gradle files.

David Lev
  • 813
  • 5
  • 12
  • It seems a little surprising that this would be the cause of the quoted error. The mechanism you speak of is *enforced* by the code whose failure produces the error, but the enforcement mechanism is not to complain but rather to simply *silently* remove the executable bit from anything that is supposed to be writable. I'd suspect instead that the *file* lacks exec permission and lost it in the process of manual copying. – Chris Stratton Jan 05 '18 at 05:23
0

I Think This is related to Marshmallow switching from OpenSSL to BoringSSL.

Your exception is occurring in the referenced library code. Contact the vendor for a fix or manually include the OpenSSL libraries to avoid the issue.

You can see this link: https://sourcedna.com/blog/20150806/predicting-app-crashes-on-android-m.html