JNI has not been able to learn the system. Revisit the HelloWorld of JNI today main reference http://www.cnblogs.com/yejiurui/p/3476565.html
This article records your feelings.
JNI Development process:
Write native Import class--Write the header file, C code, and configuration android.mk-> Project Call Nvtive class
Attention:
The decorated properties of method declarations in a 1.NATIVE class file are as follows:
package Com.tg.hz.hellojni.jni; public class Jniclient { public native string Addstr (string stra , String StrB); static public native int addint (int inta,< Span style= "color: #0000ff;" >int IntB); static {system.loadlibrary ( " Hellojnitest "); }}
2. Generate the class file: Cmd-javac (compile Native entry class file) to generate the bytecode (. Class) file, if you use Eclipse as the editor, you can *\ find the file in the project folder Bin\classes\ (package name)
3. Generate. h header file: Cmd->javah (Edit the class file in the previous step) it is easier to make an editor with Eclipse, such as
CMD under the project bin\classes file. Use the Javah package name + class name (class name does not have a suffix) to generate a. h file in the classes current directory
If you are not using the Eclipse Editor. Or there is no classes corresponding folder. It is necessary to establish the following folder tree according to the package name + class name (important), and then navigate to the COM sibling directory in cmd using the Javah package name + Class name (the class name does not have a suffix), a. h file is generated in the current directory
3. Copy the header file to the Jni folder. Create a C or CPP file with the same name and reference the header file
4.android.mk
Local_path: = $ (call My-dir) include $ (clear_vars) Local_module: = hellojnitest/* Configuration related to generated so file name and System.load The call in the Library ("Hellojnitest") */local_src_files: = com_tg_hz_hellojni_jni_jniclient.c/* Configure the C or CPP file name that needs to be compiled under JNI */include $ (build_shared_library)
5. The project address is then on the head
Initial start of JNI