JNI development environment in Android:
There are about four steps:
1.Install cygwin, install cygwin online, and install cygwin during installation (Note: Do not forget to install make and GCC in addition to common tools );
2.Download the ndk and decompress it directly;
3.Configure the environment --> This is very simple.
Find the cygwin directory, open the home/user/. bash_profile file, and add "ndk =/cygdrive/<your drive letter>/<Android ndk directory>", for example:
Ndk =/cygdrive/e/android-ndk-r5
Export ndk
4.Now that the configuration is complete, you can directly compile C/C ++ In the android project by running the "$ ndk/ndk-build" command and compress it into a library. After successful execution, it will automatically generate a libs directory to compile the generated. put the so file in it ..
Note: It must be executed in the root directory of the android project during compilation;
For example: CD $ ndk-enter the root directory of the ndk
CD samples/Hello-JNI/-Enter the directory of the hello-JNI Project
$ Ndk/ndk-Build-compile the project
Find the project directory and find that a libs directory is the compiled result. Open it. If there is a libhello-jni.so, this file will work.
Note: : Some errors may occur in these steps.
1. The following message is displayed during compilation:
Error: you are using a non-cygwin compatible Make program.
This means that the make tool you use is not cygwin. Later, we found that wingw was configured in my environment and was not prompted after the temporary deletion.
2. The following message is displayed during compilation:
Can't open file/cygdrive/D/Android-ndk-k/check-awk.awk
Source line number 1 source file/cygdrive/D/android-ndk-r7/build/awk/check-awk.awk
Context is
>>>< <
Android ndk: Host 'awk' tool is outdated. Please define host_awk to point to gawk or Naw
/Cygdrive/D/android-ndk-r7/build/CORE/init. mk: 258: *** Android ndk: aborting .. Stop
Find the \ ndk directory \ prebuilt \ windows \ bin \ awk.exefolder, delete or rename awk.exe, and compile the file.
3. The following message is displayed during compilation:
Cannot find 'make' program. Please install cygwin make package or define ....
This means that cygwin has not installed the make tool. I used cygwin to install it online again, select the same installation directory, and re-check the make tool. Other tools previously installed will not be deleted.