如果使用创建的ndk lib,有没有不包含.so文件的方法? [英] Is there a way to don't include .so file if I use created ndk lib?
问题描述
我创建了使用NDK ArCore的Android库
I created Android lib that use NDK ArCore
https://developers.google.com/ar/develop/c/enable-arcore
然后我建立了一个lib并得到了.aar
文件.然后,我创建了一个新的示例项目,并像一个模块(导入.JAR/.AAR包)一样包含了此.aar
文件,并像依赖项一样将其链接了起来,所以一切正常.
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.
问题是-当我尝试调用使用ArCore
的方法时,出现此类错误
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)
为了修复它:
构建我的库之后,在构建目录下有一些自动生成的文件,在其中我找到了arcore-native
目录,并且有四个目录
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
我刚刚将此源移动到了main
目录下的示例项目中,现在它可以正常工作了
I just moved this source to my sample project under the main
dir and now it is completely works
问题是-实现lib时,是否可以在项目中的.so
文件中不包含此目录?也许我需要以某种方式直接将它们包括在内?
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?
建议.因为每次要求要实现我的lib的用户都会感到有些困难,同时还包含带有.so
文件的目录...
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...
推荐答案
您可以将 arcore-native 中的.so
文件放入您的.aar
文件中,它们将随您的lib一起提供
You can put the .so
files from arcore-native in your .aar
file and they will be delivered with your lib.
这篇关于如果使用创建的ndk lib,有没有不包含.so文件的方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!