【原创文章,转载请保留或注明出处:http://blog.sina.com.cn/s/blog_675eba3901010tnk.html】
I have a project about some system-layer in Android mainly using linux C programming and NDK tools. For
The source code is too simple to pasted on ....
//src hello-jni.c ------------------------------------
#include <string.h>
#include <jni.h>
#include <pthread.h>
void threadmethod()
{
}
int main(void)
{
}
And the Android.mk 's content is listed as below:
LOCAL_MODULE
LOCAL_SRC_FILES := hello-jni.c
LOCAL_LDLIBS += -llog -lpthread
include $(BUILD_EXECUTABLE)
Notice the last line , I want to build a executable app not a lib .
Don't forget add the pthread lib .
Then use ndk's command or script "ndk-build " to build an app ,push it to your phone.
Firstly I push the file in my sdcard ,but in adb-shell when I exec the command "chmod 777 hello-jni" it always fails .
Then I push into folder /data/data and exec the same command successfully .
I don't know why...
Then you can run your app on root authenticate.
With the Screenshot attached :
ps : my OS is ubuntu 10.10 with ndk-r7