Android get JNI Library dir
android, android-ndk, shared-libraries
Solution
Setting the library path through ProcessBuilder.environment() seems reasonable to me, and you can get the library directory by calling Context.getApplicationInfo():
ApplicationInfo info = getApplicationInfo();
Log.i(TAG, "native library dir = " + info.nativeLibraryDir);
Problem
I have a application that has a shared library and a small executable that uses the shared library. The small executalbe (~2kB) is in assets and I write it to the Cache Directory, which is available by calling `Context.getCacheDir()`. I can start my small executable by putting `LD_LIBRARY_PATH=/data/data/my.app.package/lib` into the environment before starting the process with `ProcessBuilder`. Is there a better way to set the library path? Is there a way to get the library directory without hardcoding it?