I've been working for a month with android ndk, so I am quite a newbie. Currently I am trying to integrate some code into a big project and have multiple problems both with NDK and gstreamer. Questions are stupid but I would be very grateful if someone helped me:
1) After I build and compile a project, do I still need all of those Android.mk files? Or can I just add .so libraries using System.loadlibrary("library")?
2) After I build my .so files, do I still need to declare all .a files as build-shared libraries and link them to the .so which needs them?
3) When I add native android support, do I need to create separate libsomename.so or choose the existing?
Maybe someone could also link me to the good article about building?
1)No, if its already compiled all you need is the so and loadLibrary call. However, if you want to update the library with your app its probably a good idea to keep them
2)No, once you have a .so file that's all you need
3)I'm not sure what you're asking there.
Related
I need to compile libmysqlclient and librtlstr for Android (in fact I could find rtlsdr, but since I need mysqlclient the issue is still there).
I followed several guides but most of them present the instruction written here http://mortoray.com/2012/08/21/android-ndk-cross-compile-setup-libpng-and-freetype/
Anyway, the package I download did not contain any configure file so I don't know how to continue.
Because the purpose of this file should only be the creation of the makefile, maybe there is a way solve this.
So my questions are:
1) Is this the right approach? Are there others easier?
2) Does a general configure file exist so that I can download and use it?
3)If not, how does the makefile has to be written? This way I should be able to overcome the abscence of configure file
I need those libraries to port a c code (which needs them) to android building an executable that I'll run on my phone (so I already have the standalone toolchain from the NDK), if it helps
1) This is right approach (may be a little bit simplified, I'm using more steps to build) for libraries, which use automake. Much easier, if library uses Cmake (must contain CMakeLists.txt), because you need only NDK. Example: cmake -DANDROID_NDK=path/to/ndk -DCMAKE_TOOLCHAIN_FILE=$NDK/build/cmake/android.toolchain.cmake -DANDROID_ABI=armeabi-v7a -DANDROID_PLATFORM=android-21 ..
2) No, also you need provide additional files (for example, Makefile.in)
3) This libraries have to use one of tools such CMake, automake etc, just Makefile or project for some IDE. So, try to find out, what of this use your libraries
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 an Android project which includes NDK code. From this code, I need to call functions from other libraries built with NDK, which I have in the jniLibs folder:
jniLibs/armeabi/libtess.so
jniLibs/armeabi-v7a/libtess.so
...
if I try to load these libraries from java, as System.loadLibrary("tess"), it works fine.
However, when I try to link my NDK library to it by adding this to build.gradle:
ndk {
moduleName "myJNILib"
stl "stlport_shared"
ldLibs "log", "tess"
}
it cannot find it.
And of course, if I don't link against it, it cannot compile myJNILib, since it can't find the symbols.
Is there anyway to make this work using gradle? Or I really need to build my library outside of gradle if I want to link with other prebuilt libraries?
What I think you'll want to do is mostly rely on the natural NDK building... stuff... I'm not sure what a good word for that is.
Anyway, you'll want to follow this tutorial. It worked for my own stuff pretty neatly. You'll also, more than likely, want to read this introduction to Android.mk files. It's very helpful for debugging and making sure you're linking correctly.
You may run into two problems in doing this:
Undefined symbol errors, which can be an absolute pain. More than likely you will want to eliminate that dependency. I spent hours on this problem and finally concluded that the file must just not be there. Somehow.
You may also run into it not being able to find an extension of the file you're working on (Ergo, it may say that foo1.so can't find the library foo2.so.# despite you having linked foo2.so. You may have to compile a .a library if that happens, but that may not be the best solution.).
Well, I hope that helps!
I'm currently trying to find a solution to have an AIR native extension including a C - library for Android that is using JNI.
So far, I tried to pack the .so lib into a jar, which then is packaged into the ane.
As I learned here, I have to unpack the .so from the .jar first in order to access it.
The code found there seems to be working for a regular android project, unfortunatly when doing this for a .jar which is then packaged into an .ane, it seems to lose scope, resulting in a
FileNotFoundException: File path/to/my/lib was not found inside JAR
I already double and triple checked all paths and the contents of my jar. It's all there and spelled correctly.
Q1: How do I get access to the .so from actionscript?
Q2: Is there any other way to package/address the .so besides the regular extension-jar into the ane?
Q3: I really don't know much about the inner working of the .ane mechanism. Is it also possible to skip the .jar-wrapping and use the .so directly from actionscript?
As always, many thanks for any input.
It becomes a bad habit of me to answer my own questions, but anyway...
Sometimes the docs can help. Here in the adobe docs I finally found the solution.
Simply copying the .so to the libs/armeabi-v7a folder in my ane package directory includes the lib into the ane, so I can use the .so from inside the java code of my extension.
Sorry for bothering.
So, I have a little C library. I want to make this library available to other devs that develop native C code in android (other libraries, native apps etc).
What's the best way to go? I don't really have much clue yet, trying to figure all this out.
I've read that there are two paths to go with the NDK: using Android.mk and using create-standalone-toolchain -- is this correct? How does each one of these works? Is there a third way without the NDK, and should this be used now that the NDK is available?
**
This may have been asked before, but I understand things have changed since the release of the NDK, as a lot of posts I find seem obsolete.
this question can have a Huge answer, I will try to be as brief as possible.
Using the Android NDK, make a new android project, create a JNI folder, and create an Android.mk file, in it, make two libs, one being your lib, exported as a shared lib and the other, a jniwrapper that will test it. Here is an example of how it was done by a guy for his own lib.
You can make a shared lib by compiling with the standalone toolchain, here is an article on the subject and also take a look at the curl Readme for android, it explains how to compile curl for Android using the standalone toolchain, I believe it's the better way to do it, and also to easier for you since you will use the cross-compiler in a regular fasion...