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

查看:20
本文介绍了安装&在 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 Native Interface 与用 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.

最后,我不知道有任何 Eclipse 插件可以帮助 NDK 开发.我所知道的关于 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天全站免登陆