Monday, June 20, 2011

Compiling JNI shared library inside android source !!!

Today I was writing my JNI app for my company project and I will share how to compile the same.

Compiling JNI Shared Library:

Step1: I moved my .c file inside external/demo_jni/ folder
Step2: Wrote my Android.mk file which goes like below

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_C_INCLUDES := $(JNI_H_INCLUDE)
LOCAL_MODULE := Demo-jni
LOCAL_SRC_FILES:= Demo-jni.c
LOCAL_PRELINK_MODULE := false
LOCAL_SHARED_LIBRARIES := libcutils
include $(BUILD_SHARED_LIBRARY)

Step3: compile the entire source code using make command
cmd: make ARCH=arm CROSS_COMPILE=<Dir-Path-android-src>/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/arm-eabi-

Step4: cd out/target/product/generic/obj/SHARED_LIBRARIES/

You will find .so shared library created in respective folder


Please drop a comment if you like it.

No comments:

Post a Comment