Ubuntu 13.04 x64 安装 Android NDK C++

it2025-04-05  14

操作系统:Ubuntu 13.04 x64

目标:安装 Android NDK C++

安装Android SDK

由于设备管理adb等程序在Android SDK里,所以需要先安装SDK(需要platform tools和至少一个版本的Android API)。

http://www.cnblogs.com/sink_cup/archive/2011/10/31/ubuntu_x64_android_sdk_java.html

安装Android NDK

下载解压缩Android NDK : http://developer.android.com/sdk/ndk/index.html

安装ant

Android使用ant进行打包,所以需要安装。

sudo apt-get install -y ant

安装jdk

ant需要jdk,而不是jre。否则会提示错误:需要 /usr/lib/jvm/java-7-openjdk-amd64/lib/tools.jar

sudo apt-get install -y openjdk-7-jdk

 

编译一个Android C++程序

参考:http://developer.android.com/intl/zh-CN/tools/sdk/ndk/index.html#native-activity

echo 选择一个例子 cd android-ndk-r8e/samples/native-activity echo 生成build.xml文件 android update project -p . -s -t android-19 echo -t android-19 是目标OS的意思,使用android list targets可以查看。如果没有安装SDK中的Android API,则targets为空出错。 echo 编译 ../../ndk-build echo 打包 ant debug echo 安装到手机或者虚拟机等设备里 adb install bin/NativeActivity-debug.apk

 如果连接了多个设备,则选择一个设备进行安装调试。

adb devices adb -s 344f722e install bin/NativeActivity-debug.apk

 

开始Android C++ hello world

安卓有2种方式使用C++:

官方文档:http://developer.android.com/intl/zh-CN/tools/sdk/ndk/index.html#Using

(1)C/C++开发动态链接库,然后在Java中以JNI的形式来调用。比如官方例子中的hello-jni

demo步骤:http://www.cnblogs.com/tanlon/archive/2011/09/04/2166719.html

参考:http://developer.android.com/sdk/ndk/index.html#gettingstarted

(2)完全使用C/C++开发app。比如官方例子中的native-activity

todo

参考:http://coolshell.cn/articles/3549.html

http://www.oschina.net/code/snippet_12_2904

http://developer.android.com/reference/android/app/NativeActivity.html

转载于:https://www.cnblogs.com/sink_cup/archive/2011/09/25/ubuntu_x64_android_ndk_cpp.html

最新回复(0)