from this article
http://marakana.com/forums/android/examples/49.html
i have seen that the application build with help of NDK do following things
1> it compile all c code (inside jni folder) and make library which stays in libs folder
2> inside .apk package also that library stays inside lib folder
and inside java file i can load that library with following code
static {
System.loadLibrary("ndk_demo");
}
Question1:
so now is there possible that instead of keeping that library as part of .apk i can install it in android system and my application load from system ?
Question2:
same way can i use some other libraries all ready installed in android like open GL, sqLite ?
Answer to both the questions is Yes you can.
Q1 :
If you want to test it you can follow this way.
1) Compile the source code using NDK.
2) Copy (adb push) the library in /system/lib of your android device. Run the Application.
When you load a library it checks either from lib folder of apk file or from /system/lib folder of the system. But to copy into /system/lib, you should remount the filesystem. For this you got to have root permissions.
Q2:
Answer to Q1 answers ths aswell. If the library is present in /system/lib, you can call the existing libraries aswell. But there is a small problem. You cannot call the functions inside the library directly because of the naming convention to be followed for jni interface. So ultimately “you have to create your own library using the existing library“.
Steps would be like this:
Pull the library(adb pull)
Write your native code which will be calling the routines of the existing library(Ex. OpenGL)
Compile your code by linking it with the prebuilt library(See NDK documentation file. It is very clearly written how to do this. You need to mention it in Android.mk file while compiling).
You will finally get a shared library which internally contains the existing library.
I did the same thing for one of the existing libraries, libsqlite. If you are stuck somewhere let me know. Thanks