For self-developed ndk, it should be a little excited to compile and run Hello-JNI.
(Ubuntu environment) The establishment of the ndk development environment is easy to stop, but there are still several days of prompts:
1. In the C/C ++ environment of Eclipse, it is best to manually install the CDT plug-in,
(See my other note. Eclipse CDT security guide.
)
Help --> install new sofeware is too difficult to install and the dependency is hard to solve.
2. After the ndk environment was set up, I was eager to test the environment, so I started to write the test according to others' examples. All failed.
The reason is:
A. I didn't clear the compiling method of the ndk application, so I had to worry about it in eclipse.
JNI. h and other header files cannot be found, and eclipse cannot compile.
The C file in the project cannot be added directly. The error reported by the JNI variable of the native method in the Java file causes me to doubt whether the environment is not properly configured or the installed CDT is incomplete, because the dependency is not considered during manual installation. Confused.
B. view the ndk Doc.
How to Use ndk in docs/howto. txt.
There are two ways to compile:
1) compile in the target project directory:
$CD android-ndk-r5/samples/Hello-JNI
Enter the example directory
Execute the ndk-build script
2) Compile in any directory:
$Ndk-Build-C $ ndk/samples/Hello-JNI
Use-C to point out the project directory path
Note: No matter which one is compiled, after successful compilation, the libs and OBJ subdirectories will be generated in the current directory.
3. Open the eclipse refresh hello-JNI project and run to see the effect.