and prebuilt static library

Java language used in Android allow to communicate to external libraries written in C language through JNI interface. However is possible to use only dynamics libraries and there is no possibility, for obvious reasons, to use static libraries instead. In case you have a precompiled static library you need to use in your Android app you can create a dynamics as "wrapper" for your static library.

How to develop a dynamics library able to communicate through JNI is not in the main focus of this post. The only useful information available here will be how to create an able to include your precompiled static library in a dynamics library project. Basically the major info are the following:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE    := MyStaticLibName 
LOCAL_SRC_FILES := MyStaticLib.a


include $(CLEAR_VARS)

LOCAL_MODULE    := MyWrapperDynamicsLibName
LOCAL_SRC_FILES := MyWrapperDynamicsLib.c



As you can see in syntax exist a directive called LOCAL_STATIC_LIBRARIES but this name takes a bit misleading. The params to use is not the direct name of your static library but the name assigned to the module referring to the static library itself. Hope this will help.


Post a Comment