Some months ago I developed an Android Library which uses some native code in C. I developed such library in Eclipse, since Android Studio doesn't support Android NDK.
To distribute the library I compile the project as .jar (excluding the AndroidManifest.xml
). If someone wants to use the library in Eclipse all it needs to do is add the .jar in the folder /libs
as well as the pre-built C code (.so) for all the architectures. This works and the client project ends up with this files:
MyProject
---| libs/
-------| Library.jar
-------| armeabi/
-------| x86/
-------| ...
Now I want to be able to use my library in a similar way in an Android Studio project.
What I have tried:
Add Library.jar in the folder /libs
of the app module. Then, add in the build.gradle
file (in dependencies ) compile files('libs/Library.jar')
. Finally, add in jniLibs the C code (.so) compiled for all the architectures.
Meaning, I have this files:
MyProject
---| app
-------| libs/
-----------| Library.jar
-------| jniLibs/
-----------| armeabi/
-----------| x86/
-----------| ...
However, I always endup with this exception:
java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.example.app-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]] couldn't find "lib.so"
I have looked up this exception and it's generated because the system can't find the compiled C library. However, I don't know where can I put my pre-built C library in order to be found by the Library.jar.
Thank you for your answers.