Mario
Mario

Reputation: 2739

Using prebuilt static library

I looked at every question on SO and google, but still no luck.

I've been given a prebuilt static library libdroid.a that i need to use in my application.

I've tried putting it in the jni folder with an Android.mk

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := libdroid
LOCAL_LDLIBS := libdroid.a
include $(PREBUILT_STATIC_LIBRARY)

and calling it in java like

static {
        System.loadLibrary("droid");
    }

     public static native int droidCall(int num1, int num2);

but when I run the application i get

java.lang.UnsatisfiedLinkError: Couldn't load droid: findLibrary returned null

I'm thinking it's because it's not suppose to go in the JNI folder? But I tried in obj and libs folder too.

Upvotes: 1

Views: 446

Answers (1)

Alexander
Alexander

Reputation: 48272

You need to create your own shared library (*.so) which will be calling functions you need from that prebuilt static library. Then you load this .so library with System.loadLibrary and use its native functions

Upvotes: 2

Related Questions