The traditional way to debug NDK development of the program is troublesome, first to compile to JNI, but also to export Java interface, and then write a Java project, change a place and continuously change a few places, so the efficiency is very low. The most frequently used critical work paths (compile/debug) can be dramatically simplified, resulting in a doubling of development efficiency. In fact, the official Android is to provide a command-line debugging method, the C code you need to debug with the NDK directly compiled into the executable, and then to the device execution:
Use the NDK to export the standalone toolchain for later use, and under Cygwin, set the path $NDK environment variable represents, and then:
CD $NDK
Chmod-r 755 *
build/tools/make-standalone-toolchain.sh–ndk-dir= $NDK –platform=android-9–arch=arm–install-dir=/...../ Path-to-android-9
This will export a set of independent tool chains for API9 (including GCC, LD, ndk necessary files), later convenient to use, such as export to d:\android-9 below, then you can skip Cygwin, directly compiled our Hello world:
D:\android-9\bin\arm-linux-androideabi-gcc.exe Hello.c–o Hello
You can then develop the Android non-GUI application directly under the command line.
Debugging is also very simple, with adb push upload to/data/local/tmp below, and set the executable mode is 755:
ADB push hello/data/local/tmp/helloadb shell chmod 755/data/local/tmp/hello
Running is direct:
ADB Shell/data/local/tmp/hello
Do not upload to other directories, such as/sdcard, these directories mount with NOEXEC permissions, can not add executable permissions to the file, and/data/local/tmp is left to debug the command line, and does not require root permissions.
Can write some scripts, each time the compilation of the automatic upload, configuration to your EDITPLUS/VIM/NPP, one-click Compile Upload, one button to run. It's a lot more efficient to write a bunch of JNI and Java than the C code of the previous debugs.
Android NDK Export Standalone tool chain