第一步、下载 Android NDK, Revision 8b
- wget -c http://dl.google.com/android/ndk/android-ndk-r8b-linux-x86.tar.bz2
第二步:解压安装
- tar jxvf android-ndk-r8b-linux-x86.tar.bz2
第三步:修改环境变量
- vim ~/.bashrc
添加:
- export NDK_HOME=$HOME/android-ndk-r8b
- export PATH=$PATH:$NDK_HOME
保存退出,输入以下命令使之立即生效。
- source ~/.bashrc
第四步:测试
切换到NDK目录samples下的工程hello-jni下,执行ndk-build。如果能够正常执行,生成底层库*.so,则测试成功。- snowdream@snowdream:~$ cd $NDK_HOME/samples/hello-jni
- snowdream@snowdream:~/android-ndk-r8b/samples/hello-jni$ ndk-build
- 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