아래순서대로 고대로 따라했습니다....근데...
make명령어를 쓰면
Android NDK: The APP variable is undefined or empty.
Android NDK: Please define it to one of:
Android NDK: You can also add new apllications by writing an Application.mk file.
Android NDK: See docs/Application-mk.txt for details.
build/core/main.mk:71: *** Android NDK: Aborting . stop.
이라는 오류메세지가 나오고요..
ndk-build 명령어를 사용하면
Android NDK: Your APP_BUILD_SCRIPT points to an unknown file: /home/Administrator/android-ndk-r4b/samples/NdkExample/jni/Android.mk
/home/administrator/android-ndk-r4b/build/core/add-application.mk:98: ***Android NDK: Aborting... .Stop.
이라는 오류 메세지가 나옴니다...
도대체 무엇이 잘 못된건가요?
제발좀 도와주세요...jni만드는것 자체가 넘 힘들어요...ㅠㅠ
1. make a new 'NdkExample' project under the 'ndk-root/apps' folder.
2. make a JNI java file(class) for wrapping.
public class NdkExample {
static {
System.loadLibrary("NdkExample");
}
public native String stringFromJni();
}
3. make a 'Application.mk' file under the 'ndk-root/apps/NdkExample' folder.
APP_PROJECT_PATH := $(call my-dir)/project
APP_MODULES := NdkExample
4. make a 'NdkExample/project' and make 'jni' and 'libs' folder under the 'project' folder.
5. make a 'Android.mk' file under the 'jni' folder.
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := NdkExample
LOCAL_SRC_FILES := NdkExample.c
include $(BUILD_SHARED_LIBRARY)
6. move to 'NdkExample/bin' folder and make a header file from the 'NdkExample.class' file
javah com.example.NdkExample
7. move the header file to 'NdkExample/project/jni' folder and rename to 'NdkExample.h' for using easier.
8. make a 'NdkExample.c' file under the 'NdkExample/project/jni' folder.
#include "NdkExample.h"
#include <string.h>
jstring Java_com_example_NdkExample_stringFromJni(JNIEnv *env, jobject thiz)
{
return (*env)->NewStringUTF(env, "Hello world from native code.");
}
9. compile the project under the 'ndk-root' folder.
make APP=NdkExample
NDK 빌드가 참.. 별거아닌데 처음엔 햇갈릴수 있어요...
첨부터 새프로젝트를 만들어서 해보지 마시고,. NDK에서 제공하는 샘플 프로그램을 빌드해서 돌려보세요..
그걸로 이해하고 그담에 새프로젝트로 해보세요...
일단... 지금 NDK 버젼이 r4시라면 호스트 셋업이 필요없구요..
프로젝트 안으로 들어가서
$ cd android-ndk-r4/samples/hello-jni/
$ /home/(본인계정)/android-ndk-r4/ndk-build -B
요런식으로 빌드하시구요...
NDK가 옛날버젼이면...
그 폴더 들어가서
build/host-setup.sh 하시고..
make APP = hello-jni
이런식이네요..
NDK에서 빌드하고나서 이클립스에서 임포트해 쓰세요,,^^