Is there a way to don't include .so file if I use created ndk lib?

帅比萌擦擦* 提交于 2019-12-13 02:48:54

问题


I created Android lib that use NDK ArCore

https://developers.google.com/ar/develop/c/enable-arcore

Then I built a lib and got .aar file. Then I created new sample project and included this .aar file like a module (import .JAR/.AAR package) and linked it like dependency, so all works fine.

Issue is - when I try to call method that use ArCore I am getting such error

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.ar, PID: 7822
    java.lang.UnsatisfiedLinkError: dlopen failed: library "libarcore_sdk_c.so" not found
        at java.lang.Runtime.loadLibrary0(Runtime.java:1016)
        at java.lang.System.loadLibrary(System.java:1669)
        at com..libtetplayer.JniInterface.<clinit>(JniInterface.java:32)
        at com..libtetplayer.JniInterface.createNativeApplication(Native Method)
        at com.example.ar.MainActivity.onCreate(MainActivity.kt:20)
        at android.app.Activity.performCreate(Activity.java:7326)
        at android.app.Activity.performCreate(Activity.java:7317)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3072)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3235)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1926)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:6990)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1445)

In order to fix it: After I build my lib there are some autogenerated files under build dir, there I found arcore-native dir and there four dirs

I just moved this source to my sample project under the main dir and now it is completely works

Question is - is there is a way to don't include this dirs with .so files in project when implementing the lib? Maybe I need to include them directly to lib somehow?

P.S. Because it is a little bit hard everytime ask user that want to implement my lib also include a few dirs with .so files...


回答1:


You can put the .so files from arcore-native in your .aar file and they will be delivered with your lib.



来源:https://stackoverflow.com/questions/58955968/is-there-a-way-to-dont-include-so-file-if-i-use-created-ndk-lib

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