Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Now let’s look at an example of how to set up and use the NDK for your own Android applications using Eclipse. To create a new Android application that calls into native code, take the following steps:
1. Begin by creating a new Android project in Eclipse.
2. Navigate to your project directory and create a subdirectory called /jni. Inside this directory, place two C files: native_basics.c and native_opengl2.c.
3. In the /jni subdirectory, create a file called Android.mk. A sample Android.mk file might look like this, the one used in our sample application:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_LDLIBS := -llog -lGLESv2
APP_ABI := all
LOCAL_MODULE := simplendk
LOCAL_SRC_FILES := native_basics.c native_opengl2.c
include $(BUILD_SHARED_LIBRARY)