1

I'm working with an app that implements a library which use 2 files .so.

So the photo is:

APP --> LIBRARY

inside LIBRARY I have a folder called jniLibs at the same level of "java" or "res", with 2 subfolders storing a lib.so.

APP
 |    
 ---LIBRARY
       |
       --- java
       --- res
       --- jniLibs
              |
              --- arm64-v8a ----> lib.so
              --- armeabi-v7a --> lib.so

Structure

I'm trying to get this path with:

private val path = "${context.applicationInfo.nativeLibraryDir}/lib.so"

but when I run the app and call the library, it's returns me an IOException because the path doesn't exist.

java.io.IOException: Cannot run program "/data/app/~~UKA0xfuymw9X6WLqOTKpgQ==/es.test.testingapp-SYQbmzLkH63ebcNwAoJskg==/lib/arm64/lib.so" (in directory "/data/user/0/es.test.testingapp/files"): error=2, No such file or directory

How I can get this to work, I think that the problem is that with the context of the app the folder is in another location but I don't know how to solve it.

My library is created separate, with com.android.library, and I'm adding to the project of the main app with an Implementation in build.gradle and settings.gradle.

Thank you

Víctor Martín
  • 3,352
  • 7
  • 48
  • 94
  • Please clarify how you created your library. Is it in the codebase like a directory or a Android module? – Morrison Chang Oct 14 '22 at 09:42
  • My library is created separate, with com.android.library, and I'm adding to the project of the main app with an Implementation in build.gradle and settings.gradle. – Víctor Martín Oct 14 '22 at 09:49
  • Seems similar to: [How to correctly find native lib path in Android?](https://stackoverflow.com/q/63134761/295004) and [Hosting an executable within Android application](https://stackoverflow.com/a/58748468/295004) – Morrison Chang Oct 14 '22 at 10:03
  • Yeah, I had followed those posts, but for some reason the compilation is not copying the libs in the data folder. I don't know if it is because the library has in build.gradle --> "id 'com.android.library'" instead of "id 'com.android.application' – Víctor Martín Oct 14 '22 at 11:45

0 Answers0