2

I have a static library(libnative.a) which I have generated for arm architecture. Now I want to use the library in my android application using NDK. My Android.mk has

LOCAL_STATIC_LIBRARIES := libnative

i was also trying to load the library in java using System.loadlibrary("path/to/the/libnative.a");

But I get error:

java.lang.UnsatisfiedLinkError: Couldn't load libnative.a from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.example.testsdk-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.testsdk-2, /system/lib]]]: findLibrary returned null

Please help me in loading static libraries in android application. I've already worked with shared libraries. I'm very much familier with loading .so files. Thanks in Advance :)

Kishore
  • 952
  • 2
  • 11
  • 31

1 Answers1

3

You can't load a static library - only shared libraries are actually included in the APK and installed on the phone. When you include the static library when building a shared library (by using LOCAL_STATIC_LIBRARIES := libnative in your Android.mk), it actually gets linked into the shared library so that the shared library contains all the code from the static one. Therefore you only need to load the shared library using System.loadLibrary().

mstorsjo
  • 12,983
  • 2
  • 39
  • 62
  • Thanks for the answer.. Is it possible to use static library in application without packing it in APK. I mean can we dynamically point to static library which can be resided somewhere on device? – Kishore Sep 16 '14 at 10:30
  • 1
    No, that's not possible, as far as I know. A static library can only be used as an intermediate step while building a shared library. – mstorsjo Sep 16 '14 at 11:02