If you want to make a ndk developing environment.
You can search for many useful sites in an internet.
I introduced my case. In fact, I have spent much time which was failed.
This is a rough scenario so, when you follow this scenario, you could miss detailed things.
( So, I recommend using this guide only as a reference. )
1. First up, you should install cygwin.. When installing, you should check g++, gcc, swing, vim and make manually.
(If you don't check them, when building it would be failed. )
2. Second up, you should install ndk.
3. Third up, in the activity which uses a native function, you should declare following.
static {
System.loadLibrary("csource");
}
// declare the native code function - must match ndkfoo.c
private native String invokeNativeFunction();
4. make a natvie file as *.c
jstring Java_com_example_ndkexample_MainActivity_invokeNativeFunction(JNIEnv* env, jobject javaThis) {
return (*env)->NewStringUTF(env, "Hello from C Code!");
}
The bold line means a package and the following word means the class which uses a native function. and the last word means the native function name.
5. make an Android.mk
( refer to the other example in detail. )
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
# Here we give our module name and source file(s)
LOCAL_MODULE := csource
LOCAL_SRC_FILES := csource.c
include $(BUILD_SHARED_LIBRARY)
6. execute the ndk-build which is placed in the ndk path.
( At that time, you should be in the jni folder. )
If you success, the libs folder get to have a so file.
Ok. I have attached the sample example zip.
'Android' 카테고리의 다른 글
Custom view 생성 (0) | 2013.05.17 |
---|---|
SurfaceView in Layout (0) | 2013.05.14 |
custom font setting (0) | 2013.05.07 |
Unable to execute dex: method ID not in [0, 0xffff]: 65536 Conversion (0) | 2013.04.30 |
libs jar folder (0) | 2013.01.29 |