Android NDK Export Standalone tool chain

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.