I used to have a casual experience with JNI on android. So I subconsciously think this is nothing.
But this is actually not the case. The following are some of the issues that have plagued me during JNI development:
JNI development steps:
Step 1 declare the function definition in the java File
Step 2: Use the javah tool to compile the class file compiled by the java file into the. h header file.
Step 3 compile a specific function implementation in C Based on the H file.
Step 4: Compile the. c file as the so Library (ndk needs to be used here) and then call it in java.
Path of the header file:
1. Adjust the current path to the path before com, that is, the path of the normal java command,
2. The command for generating the header file is javah-classpath.-jni package name + class name.
Question about generating the so file:
1. to generate the so file, you must create a new jni directory in the android Application project, and then perform operations in the jni directory.
2. Enter the jni directory in the cygwin environment and enter $ NDK/ndk-build for automatic compilation.
JNI Syntax:
This is a complicated part in jni development.