Build an android ndk R7 development environment in Ubuntu

Source: Internet
Author: User

By referring to the information on the network, record the process, experience, and problems of building the android ndk R7 Development Environment on Ubuntu. Hope to help you.

1. Download the package android-ndk-r7-linux-x86.tar.bz2 (you can copy it to the path you want to store, for example, my path is/home/XXX/android_install)
2. Enter the package storage directory (CD/home/XXX/android_install) for decompression,
Command: Tar jxvf android-ndk-r7-linux-x86.tar.bz2; Name it android-ndk-r7 after decompression.
3. I am used to changing permissions,
Command: chmod 777-r android-ndk-r7
4. Set environment variables for ndk-build (for ease of use) and modify your. bashrc File
1) Open ~ /Edit the bashrc File
Command: gedit ~ /. Bashrc
2 )~ /Add the following two lines of text at the end of the bashrc File
Export ndk_home =/home/XXX/android_install/android-ndk-r7/
Export Path = $ path: $ ndk_home
3) Save ~ /. Bashrc file and exit.
5. Make the settings take effect immediately
Command: Source ~ /. Bashrc
6. test whether the configuration is OK.
Command: ndk-build
Print the information after execution:
/Home/XXX/android_install/android-ndk-r7/prebuilt/linux-x86/bin/awk: 1: Elf: not found
/Home/XXX/android_install/android-ndk-r7/prebuilt/linux-x86/bin/awk: 4: syntax error: Word unexpected (expecting ")")
Android ndk: Host 'awk' tool is outdated. Please define host_awk to point to gawk or nawk!
/Home/XXX/android_install/android-ndk-r7/build/CORE/init. mk: 258: *** Android ndk: aborting .. Stop.
If ndk-build command not found is not displayed, the configuration is successful.
7. Test the demo program.
Command: ndk-Build-C/home/XXX/android_install/android-ndk-r7/samples/Hello-JNI/(you can also directly execute ndk-build in this directory)
An error is prompted:
/Home/XXX/android_install/android-ndk-r7/prebuilt/linux-x86/bin/awk: 1: Elf: not found
/Home/XXX/android_install/android-ndk-r7/prebuilt/linux-x86/bin/awk: 4: syntax error: Word unexpected (expecting ")")
Android ndk: Host 'awk' tool is outdated. Please define host_awk to point to gawk or nawk!
/Home/XXX/android_install/android-ndk-r7/build/CORE/init. mk: 258: *** Android ndk: aborting .. Stop

After searching online, the system was originally 32-bit and the 64-bit program could not be run. So I found a solution on the Internet: delete files under prebuilt, delete awk directly, or rename awk. In short, this awk file is not used. After deletion or rename, The ndk will use the awk program that comes with the Linux system.
1) CD/home/XXX/android_install/android-ndk-r7/prebuilt/linux-x86/bin
2) root @ xxx:/home/XXX/android_install/android-ndk-r7/prebuilt/linux-x86/bin # ls
Awk make SED
3) root @ xxx:/home/XXX/android_install/android-ndk-r7/prebuilt/linux-x86/bin # mv awk awk_back
4) root @ xxx:/home/XXX/android_install/android-ndk-r7/prebuilt/linux-x86/bin # cd ../../../
5) execute the command: root @ xxx:/home/XXX/android_install/android-ndk-r7 # ndk-Build-C samples/Hello-JNI/
Print Information:
Gdbserver: [arm-linux-androideabi-4.4.3] libs/armeabi/gdbserver
Gdbsetup: libs/armeabi/GDB. Setup
Compile thumb: hello-JNI <= hello-jni.c
Sharedlibrary: libhello-jni.so
Install: libhello-jni.so => libs/armeabi/libhello-jni.so

Related Article

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.