安装 &在 Eclipse 中使用 Android NDK [英] Installing & using the Android NDK in Eclipse

查看:18
本文介绍了安装 &在 Eclipse 中使用 Android NDK的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在 Eclipse (MAC OSX) 中运行了一段时间的 Android SDK.我已经下载了 NDK 并在 Eclipse 中安装了 C/C++ 工具,但是谁能指导我使用 NDK?例如,我是否只是像平常一样创建一个 Android 项目,然后使用 NDK 来构建它?

I've been running the Android SDK for a while now in Eclipse (MAC OSX). I've downloaded the NDK and installed the C/C++ tools in Eclipse, but could anyone guide me on using the NDK? For example, do I just create an Android project like normal and build it with the NDK instead?

如果有人知道的话,真的可以做一个像样的教程.

Really could do with a decent tutorial if anyone know of any.

好的,所以我现在安装了 NDK(我认为)但是有人知道如何使用它吗?我做到了这一点(取自 这里):

OK so I have the NDK installed now (I think) but does anyone have any idea how to use it? I got as far as this (taken from here):

运行终端

cd ~/android-ndk-1.5_r1

cd ~/android-ndk-1.5_r1

使 APP=hello-jni

make APP=hello-jni

为了运行 hello-jni 示例应用程序,但我在终端中收到错误消息:

In order to run the hello-jni sample application, but I get an error in terminal saying:

Android NDK:APP 变量定义为未知应用程序:hellojni
Android NDK:您可能想要使用以下之一:
构建/核心/main.mk:81: *** AndroidNDK:中止 .停止.

Android NDK: APP variable defined to unknown applications: hellojni
Android NDK: You might want to use one of the following:
build/core/main.mk:81: *** Android NDK: Aborting . Stop.

知道为什么吗?

推荐答案

正如我所描述的那样,在 Eclipse 中构建一个使用 NDK 的 Android 应用程序需要两个步骤.

As simply as I can describe it, building an Android app from within Eclipse that uses the NDK requires two steps.

首先,在终端中,您需要在项目上运行 NDK 构建脚本.cd 进入项目目录的根目录,然后在该目录中执行 ndk-build 脚本.

First, inside your terminal you need to run the NDK build script on your project. cd into the root of your project directory and then execute the ndk-build script within that directory.

例如:

cd ~/workspace/hello-jni
./~/android-ndk-1.5_r1/ndk-build

执行此操作后,您应该会看到一些输出,导致在项目目录的 obj 目录中创建 *.SO 文件.

After doing this, you should see some output that results in the creation of a *.SO file within the obj directory within your project directory.

获得 *.SO 文件后,通过 Eclipse 使用 Android NDK 构建应用程序的最后一步是像构建任何其他应用程序一样使用 Eclipse 构建它,然后部署它以进行测试.

Once you have the *.SO file, the final step to building an application with the Android NDK through Eclipse is to build it with Eclipse like you would any other application and then deploy it for testing.

如果您对 C/C++ 代码进行任何更改,您将需要重复第一步并重新生成 *.SO 文件,然后再次从 Eclipse 中构建和部署您的应用程序.

If you make any changes to the C/C++ code you'll need to repeat step one and regenerate your *.SO file before building and deploying your application from within Eclipse again.

我想指出,通过使用 Android NDK,您的 Android 应用程序仍然基于 Java.它们只是通过 Java 本机接口与用 C/C++ 编写的代码进行通信.

I would like to note that by using the Android NDK your android apps are still based upon Java. They're just communicating with code written in C/C++ by way of the Java Native Interface.

最后,我不知道有任何有助于 NDK 开发的 Eclipse 插件.我所知道的关于 NDK 的一切我都从官方 Android NDK 文档 中了解到.请随时发表评论,如果有什么我可以在回复中澄清的地方,请告诉我.

Finally, I am not aware of any Eclipse plugins that will aid with NDK development. Everything I know about the NDK I have learned the official Android NDK documentation. Please feel free to comment and let me know if there anything I can clear up in my response.

这篇关于安装 &在 Eclipse 中使用 Android NDK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆