The basic process is the development of Eclipse for NDK:
Create an Android project ---> function to complete the preparation of java, jni add interface function (native function) is added ---> Add jni folder, add Android.mk and source files ---> implemented in the source file interface function ---> ndk-build with the source files compiled into lib library ---> start Android emulator, install and run the project.
For example:
1, open Eclipse, add a android project. Name of the project is IDETTest, and then complete the Activity name (IDETest) and java package (com.test.IDETest) of the prompts. Note java package name is best not underlined, calls may fail in the future jni call, because the format interface functions jni is the name of the package _Activity Java_java name _ function declaration
2, to complete the preparation of java code introduced ndk cross compiler is called in the class of calls required jni:
}
At the same time in the class declaration native function (in the C file is created, with the NDK cross compiler)
public native String generateID(String label);
Complete java file looks like this:
}
3, add a folder in IDETest project, named jni. C add modules to achieve in the jni folder files (.c and .h files engineering) and Android.mk file
C content file module (IDETest.c) of
#include <string.h>
Android.mk file
4, compile the source code for the library file.
Into the project directory
root@XXX-laptop:~/IDETest# ls
Compiled library files in there.
5, start the Android emulator to run the project.
Reproduced in: https: //www.cnblogs.com/imagelab/archive/2011/08/20/2147023.html