Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request: Dynamic feature module handling native libs #30

Closed
elmira-asd opened this issue Sep 23, 2019 · 13 comments
Closed

Request: Dynamic feature module handling native libs #30

elmira-asd opened this issue Sep 23, 2019 · 13 comments
Assignees

Comments

@elmira-asd
Copy link

elmira-asd commented Sep 23, 2019

i'm using Dynamic Feature Module for a feature which has third SDK library as .AAR file.
When analysing the apk i found out this sdk is using Native / C++ codes and the structure is like:
Screen Shot 2019-09-18 at 2 43 20 pm

i know that in dynamic module when we want to use native libs we should implement for instance something like :SplitInstallHelper.loadLibrary(this, "tensorflowlite_gpu_gl")
however i'm getting this error:
java.lang.UnsatisfiedLinkError: dlopen failed: library "libtensorflowlite_gpu_gl.so" not found

I'm not sure in Gradle in dynamic module what should i do to be able to load those .so libs?

@crocodilys
Copy link

Hi, @elmira-asd! I encountered the same issue. Did you solve that one?

@elmira-asd
Copy link
Author

@crocodilys Hi there, first i loaded the libs kind of locally calling System.loadLibrary("c++_shared") and it worked fine, but it's not recommended if you have another libs (you can check when analysing the apk) because in . my case i should have been careful about different system/device architectures, in some devices it may crash!

@keyboardsurfer
Copy link
Member

Does this module help?

@elmira-asd
Copy link
Author

This Module will definitely help if i have those C++ libs in my libs, but they were wrapped as .AAR file. that was the reason i couldn't use SplitInstallHelper to load those libraries!
so i should have extract those files and then using SplitInstallHelper!

@elmira-asd
Copy link
Author

@crocodilys Still not recommended if you're using third SDK, so you can ask them to fix this one in their side

@keyboardsurfer
Copy link
Member

It shouldn't matter whether the .so are included via an aar or directly within the feature they're used in. The Context you're passing in to loadLibrary might though. You may have to create a new context before the library can be loaded like shown in the documentation here: https://developer.android.com/guide/app-bundle/playcore#load_native_libs

@KonsRaspopov
Copy link

@elmira-asd Still cannot understand if you were able to use TensorFlow in a dynamic feature or not. I faced the same problem. Still not sure if calling SplitInstallHelper.loadLibrary before using TensorFlow classes will help(as they will call System.loadLibrary inside and it might crash).

@keyboardsurfer
Copy link
Member

Closing this as it's not related to the sample at hand any longer. Feel free to ask a question on StackOverflow and link it here.

@kirtisinghvliv
Copy link

i'm using Dynamic Feature Module for a feature which has third SDK library as .AAR file.
When analysing the apk i found out this sdk is using Native / C++ codes and the structure is like:
Screen Shot 2019-09-18 at 2 43 20 pm

i know that in dynamic module when we want to use native libs we should implement for instance something like :SplitInstallHelper.loadLibrary(this, "tensorflowlite_gpu_gl")
however i'm getting this error:
java.lang.UnsatisfiedLinkError: dlopen failed: library "libtensorflowlite_gpu_gl.so" not found

I'm not sure in Gradle in dynamic module what should i do to be able to load those .so libs?

Hi @elmira-asd mentioned issue if you are able to fix please guide me, same issue i am facing.
Thanks for your help in advance!

@elmira-asd
Copy link
Author

i'm using Dynamic Feature Module for a feature which has third SDK library as .AAR file.
When analysing the apk i found out this sdk is using Native / C++ codes and the structure is like:
Screen Shot 2019-09-18 at 2 43 20 pm
i know that in dynamic module when we want to use native libs we should implement for instance something like :SplitInstallHelper.loadLibrary(this, "tensorflowlite_gpu_gl")
however i'm getting this error:
java.lang.UnsatisfiedLinkError: dlopen failed: library "libtensorflowlite_gpu_gl.so" not found
I'm not sure in Gradle in dynamic module what should i do to be able to load those .so libs?

Hi @elmira-asd mentioned issue if you are able to fix please guide me, same issue i am facing.
Thanks for your help in advance!

It's better to change the .ARR file rather than the app, also try to use SplitCompat.installActivity(this) instead of just calling SplitCompat.install(this) it helps immediate access to a given activity.

@imaiya
Copy link

imaiya commented Sep 10, 2023

@elmira-asd I have the same problem as you, a third-party aar contains multiple so files, and the aar already uses System.loadLibrary. How should I solve it?

@imaiya
Copy link

imaiya commented Sep 10, 2023

@elmira-asd

i'm using Dynamic Feature Module for a feature which has third SDK library as .AAR file.我正在使用动态功能模块来实现具有第三个 SDK 库作为 .AAR 文件的功能。
When analysing the apk i found out this sdk is using Native / C++ codes and the structure is like: 在分析 apk 时,我发现这个 sdk 使用 Native / C++ 代码,结构如下:
Screen Shot 2019-09-18 at 2 43 20 pm
i know that in dynamic module when we want to use native libs we should implement for instance something like :SplitInstallHelper.loadLibrary(this, "tensorflowlite_gpu_gl") 我知道在动态模块中,当我们想要使用本机库时,我们应该实现例如: SplitInstallHelper.loadLibrary(this, "tensorflowlite_gpu_gl")
however i'm getting this error:但是我收到这个错误:
java.lang.UnsatisfiedLinkError: dlopen failed: library "libtensorflowlite_gpu_gl.so" not found java.lang.UnsatisfiedLinkError:dlopen失败:找不到库“libtensorflowlite_gpu_gl.so”
I'm not sure in Gradle in dynamic module what should i do to be able to load those .so libs?我不确定在动态模块的 Gradle 中我应该做什么才能加载这些 .so 库?

Hi @elmira-asd mentioned issue if you are able to fix please guide me, same issue i am facing.您好,如果您能够解决提到的问题,请指导我,我面临着同样的问题。
Thanks for your help in advance! 提前感谢您的帮助!

It's better to change the .ARR file rather than the app, also try to use SplitCompat.installActivity(this) instead of just calling SplitCompat.install(this) it helps immediate access to a given activity.最好更改 .ARR 文件而不是应用程序,还尝试使用 SplitCompat.installActivity(this) 而不是仅仅调用 SplitCompat.install(this) 它有助于立即访问给定的活动。

The .aar file is third party and I can't change it. Strange if I kill the app and restart it, everything is fine

@lianyagang
Copy link

SplitCompat

你可真爱关闭issue,并且没有一次是有提供有效信息的。你就不能搞个demo出来吗?动态模块里面依赖aar,这个aar包含第三方so库。你会怎么去使用。搞一个demo很难吗。天天就爱关闭issue。你的kpi是靠这个来的吗

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants