You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TLDR : ReLinker is looking in /lib folder of my android project and not also in the /jni folder of my aar file (which contains some so files) which result with a java.lang.UnsatisfiedLinkError
Create the aar file including so files
I created an aar library which contains a few shared-objects. Those so files are stored in the /jni folder according to Android documentation. So the compilation of the aar library is not a problem.
Import aar in Android project
Then when I import the aar file in an android project, I use relinker.recursive() to get my so file. But it seems that relinker is looking only in the /lib folder of the android project, and not also in the /jni folder of the aar library.
Shared libraries are always stored in lib directory in the APK. That's where the system looks for them. There's no reason for ReLinker to look anywhere else, i.e. this is not ReLinker's problem.
AARs from Maven repos and other modules are processed correctly. Perhaps there's an issue with how raw AAR files get processed by Android Gradle Plugin. In which case create a small repro project and open an issue in Google Issue Tracker.
If the library and the application are in the same root project, you can have the application module depend on the library module:
implementation(project(":my_library"))
If they're in separate root project, publish the library to a maven repo (you can use mavenLocal() for testing).
Avoid manually working with AARs. AAR does not contain metadata required to resolve dependencies. You would have to duplicate dependency specifications between the library and the application. That means the person who writes application would also need to have access to the library's build.gradle... and even if you do, good luck keeping them in sync.
Your remote library needs the shared native libs in src/main/jniLibs/<abi>/ directory. Upon building & publishing of your Library as an aar, it will be packaged in the aar's jni directory. When imported to your project, the .so files will be included in the apk's lib/ directory when building the app.
Placing the .so files in the jni dir of your library, they won't be included in the published aar. Must be in the src/main/jniLibs/<abi>/ dir.
TLDR : ReLinker is looking in /lib folder of my android project and not also in the /jni folder of my aar file (which contains some so files) which result with a
java.lang.UnsatisfiedLinkError
Create the aar file including so files
I created an aar library which contains a few shared-objects. Those so files are stored in the /jni folder according to Android documentation. So the compilation of the aar library is not a problem.
Import aar in Android project
Then when I import the aar file in an android project, I use relinker.recursive() to get my so file. But it seems that relinker is looking only in the /lib folder of the android project, and not also in the /jni folder of the aar library.
Of course if I copy/paste those .so files in the android project those library will be loaded using ReLinker. But that's not what I try to achieve.
For more information about my problem, I posted on Stackoverflow
The text was updated successfully, but these errors were encountered: