plaisthos
plaisthos

Reputation: 6323

Android get JNI Library dir

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.

  1. Is there a better way to set the library path?

  2. Is there a way to get the library directory without hardcoding it?

Upvotes: 3

Views: 3494

Answers (1)

Owen
Owen

Reputation: 4049

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);

Upvotes: 5

Related Questions