Android.mk 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 Android.mk 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 $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)

LOCAL_MODULE    := MyWrapperDynamicsLibName
LOCAL_SRC_FILES := MyWrapperDynamicsLib.c

LOCAL_STATIC_LIBRARIES := MyStaticLibName

include $(BUILD_SHARED_LIBRARY)

As you can see in Android.mk 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.

Comments

Popular posts from this blog

Access GPIO from Linux user space

Android: adb push and read-only file system error

Tree in SQL database: The Nested Set Model