Shared Libraries in Developer M Preview

人盡茶涼 提交于 2019-12-10 17:32:48

问题


I am trying to test out my application on the Android M dev preview.

My application is using a Shared library, which I have placed in jni/libs/armeabi inside of Android Studio. I believe when it calls System.loadLibrary("myLib") it is throwing the following UnsatisfiedLinkError. Is anyone else having this issue? Android 5.x has no problem with this.

06-02 08:24:28.004  16505-16505/com.me.workflow E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: com.me.workflow, PID: 16505
    java.lang.UnsatisfiedLinkError: dlopen failed: library "{Path}/Android/Workflow/mobile/src/main//obj/local/armeabi/myLib.so" not found
            at java.lang.Runtime.loadLibrary(Runtime.java:368)
            at java.lang.System.loadLibrary(System.java:1076)
            at com.me.workflow.service.WorkflowService.<clinit>(WorkflowService.java:108)
            at com.me.workflow.activities.BaseServiceActivity.startWorkflowService(BaseServiceActivity.java:501)
            at com.me.workflow.activities.WelcomeActivity.deployAndroidSetup(WelcomeActivity.java:639)
            at com.me.workflow.activities.WelcomeActivity.onFileOperationCompleted(WelcomeActivity.java:842)
            at com.me.workflow.tasks.CopyFromAssets.onPostExecute(CopyFromAssets.java:76)
            at com.me.workflow.tasks.CopyFromAssets.onPostExecute(CopyFromAssets.java:42)
            at android.os.AsyncTask.finish(AsyncTask.java:649)
            at android.os.AsyncTask.-wrap1(AsyncTask.java)
            at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:666)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:148)
            at android.app.ActivityThread.main(ActivityThread.java:5401)
            at java.lang.reflect.Method.invoke(Native Method)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:725)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:615)

Update:

I have received some feedback on the issue. In my Android.mk file I have the line below, currently the belief is that this path is not correct and that it is not finding the file because of it.

LOCAL_SRC_FILES    := libs/$(TARGET_ARCH_ABI)/myLib.so

https://code.google.com/p/android-developer-preview/issues/detail?id=2239


回答1:


I solved my problem, by making sure my prebuild of the library had a soname set. See the following Android Developer Preview issue thread

https://code.google.com/p/android-developer-preview/issues/detail?id=2239

item number 10 in the thread talks about my prebuilt needing to have the soname set, which I previously had not.

so in my library build script I added -Wl,-soname,lib{mylibname}.so to my LDFLAGS variable

export LDFLAGS="--sysroot ${TOOL_PREFIX}/sysroot -L${PREFIX}/lib -L${TOOL_PREFIX}/lib ${LDFLAGS_EXTRA} -Wl,-soname,libmylib1.0.so"


来源:https://stackoverflow.com/questions/30596250/shared-libraries-in-developer-m-preview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!