I have to use an external library with '.a' extensión but I do not have any idea how to use it. I am totally lost, I don´t know if I have to import it or not and if I have to imported I don´t know how.
How can I use this library in my project?
When we want to invoke native library in Android apps, we can only use dynamic library, which usually ends with .so extension.
So that means you have to build a dynamic library based on .a file.
Related
I have looked at Use prebuilt JNI library in Android Studio 3.1 and How to use .so in a second project in Android?. The first is trying to get a library file without headers working and the other seems to be focusing on a specific issue with his build (although there's some useful information there). I'm relatively new to app development and especially to native development on android. I've gotten a build with the JNI library and some c++ code working, but that seems to be just for building from source.
It's probably a simple answer, but I haven't been able to find documentation on this specifically in the android developers documentation. I'm interested in understanding the correct (or most conventional) place to put and way to use a precompiled library (module/lib/*.so and module/include/*.h) in an android project. Would I even need to use JNI or the NDK if the library is built with another build tool? Another project I have has a native library source object (*.so) in ./obj/local, ./libs, and in many other folders related to JNI. I'm guessing it would be somewhere in there, but I'd like to know what is conventional.
For some context, I'm trying to work with the essentia library. I have followed the guide on compiling for Android and have a build with the general hierarchy mentioned above (essentia/lib and essentia/include) that seems to be working.
I have developed a library for Windows in VS2013. It does not have a GUI, only (mathematical) code.
I would now like to create an APK file so that I can use my library on Android.
I hope that I don't have to re-write everything from scratch for Android.
What would currently be the best solution so that I can keep most of my C++ files while creating the APK?
Thank you for the help!
You can compile your library with the Android NDK, which produces a .so file.
Android applications are written in Java. To use your library, you should first load your .so library and then you can access its function via JNI.
Is it possible and if so how do you use/reference the .so version of the cocos2d-x library instead of the libcocos2dx.jar as most tutorials tell you to do. ie cocos2d-x has some project directory called Android and there's a project there with java code that will compile and create a libcocos2dx.jar file which I can then reference in my own project.
But my question is why reference .jar java library instead of .so library, so how do I reference in my own project so that I use something like libcocos2dx.so instead of referencing library project libcocos2dx.jar?
I guess I'm thinking the performance will be better if I use .so native library.
Forgot I even posted this, anyway in case helps others, you can simply extract JAR contents and get the .so from there and put it in libs and there edit the main activity java code to reference it that way. Related helpful links:
*.so library from included *.jar involves UnsatisfiedLinkError
How to bundle a native library and a JNI library inside a JAR?
Not really sure if there's any performance impact to bundling the .so inside jar or not and not sure what problem if any that may cause if the .so inside is too platform specific etc, so I prefer to keep .so's outside of jars, directly in lib folder.
I have an android library project, which I want to include to my titanium android module. In the documentation I found no way to reference the library project. For adding a third party library the documentation has a guide to include a .jar file. So I tried to add the .jar file.
The library project also depends on native libraries (.so files) and resources. I experimented a little bit and I got it somehow working, that the ressources and native libraries are included in my .apk. The problem is: at runtime I get a ClassDefNotFoundError.
I tried pretty much everything and I don't know how to get this running.
BTW I'm a newbie, so maybe it is not even possible what I'm trying to do.
Can anyone please help?
This
fixed it. Just modify the script.
I have .so library and it's 'JNICall' class, which is an interface for it. They was wrote not by me. To be honest, I decompiled one apk to get them. So the question - It is possible to use them in my project, and how I can do this?
Try to find proper documentation for your library otherwise it'll be difficult to integrate,
as for including the so file in your project follow this:
How do I import a native library (.so file) into Eclipse?