eclipse 找不到 ndk-build 作为命令

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5847532/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 16:15:15  来源:igfitidea点击:

ndk-build not found as a command

androideclipseandroid-ndk

提问by user669231

I have been working with Android SDK for a while & just came across an requirement to use the NDK

我已经使用 Android SDK 有一段时间了,刚遇到一个使用 NDK 的要求

So, I downloaded the Android NDK for Windows. Jumping on the first example, when I am trying to build the library using the process defined in the NDK example

所以,我下载了适用于 Windows 的 Android NDK。跳到第一个示例,当我尝试使用 NDK 示例中定义的过程构建库时

http://developer.android.com/sdk/ndk/overview.html

http://developer.android.com/sdk/ndk/overview.html

Specifically the command /ndk-build from the command line

特别是命令行中的命令 /ndk-build

I am getting the error

我收到错误

ndk-build is not recognized as an internal or external command, operable program or batch file

ndk-build 不是内部或外部命令,也不是可运行的程序或批处理文件

I have added the path for ndk-build in the PATH variable and even tried calling the command going to the folder, still the same error

我已经在 PATH 变量中添加了 ndk-build 的路径,甚至尝试调用去文件夹的命令,仍然是同样的错误

Does anybody have a clue?

有人有线索吗?

回答by Scott C Wilson

Guess that should have been an answer instead of a comment.

猜猜这应该是答案而不是评论。

You must use Cygwin as your shell in order to run ndk-build.
See http://www.cygwin.com/

您必须使用 Cygwin 作为 shell 才能运行 ndk-build。
http://www.cygwin.com/

回答by JPM

Once you have Cygwin installed you can have Eclipse automatically build your project for you by:

安装 Cygwin 后,您可以通过以下方式让 Eclipse 自动为您构建项目:

  1. Right click on your project, pick properties.

  2. Select "builders" from the left-hand list.

  3. Click "New..." on the right side.

  4. Select "Program" as the configuration type. I name mine "Native Builder"

    Location - c:\cygwin\bin\bash.exe

    Working Directory - c:\cygwin\bin

    Arguments -

    (for NDK r3): --login -c "cd /cygdrive/c/Android_NDK && make APP=myapp"

    (for NDK r4): --login -c "cd /cygdrive/c/ && /cygdrive/c/Android_NDK/ndk-build"

  1. 右键单击您的项目,选择属性。

  2. 从左侧列表中选择“builders”。

  3. 单击右侧的“新建...”。

  4. 选择“程序”作为配置类型。我将我的名字命名为“本地生成器”

    位置 - c:\cygwin\bin\bash.exe

    工作目录 - c:\cygwin\bin

    参数 -

    (对于 NDK r3):--login -c "cd /cygdrive/c/Android_NDK && make APP=myapp"

    (对于 NDK r4):--login -c "cd /cygdrive/c/ && /cygdrive/c/Android_NDK/ndk-build"

Make sure you have the two hyphens before login and the quotes after the hyphen-c

确保您在登录前有两个连字符和连字符-c 后的引号

  1. Now go to the refresh tab

  2. Check "Refresh resources upon completion"

  3. Select "Specific resources"

  4. Click on the "Specify resources" button and select your project's lib directory.

  5. Check "Recursively include sub-folders"

  6. Now go to the build options tab

  7. Check "Allocate Console"

  8. Check "Launch in background"

  9. Check "Run the builder After a Clean"

  10. Check "Run the builder During manual builds"

  11. Check "Run the builder During auto builds"

  12. Check "Specify working set of relevant resources"

  13. Click on "Specify Resources"

  14. Select your project's JNI directory and all files within.

  15. Now click OK on the bottom.

  1. 现在转到刷新选项卡

  2. 勾选“完成后刷新资源”

  3. 选择“特定资源”

  4. 单击“指定资源”按钮并选择项目的 lib 目录。

  5. 选中“递归包含子文件夹”

  6. 现在转到构建选项选项卡

  7. 勾选“分配控制台”

  8. 勾选“在后台启动”

  9. 选中“清洁后运行构建器”

  10. 选中“在手动构建期间运行构建器”

  11. 选中“在自动构建期间运行构建器”

  12. 勾选“指定相关资源的工作集”

  13. 点击“指定资源”

  14. 选择项目的 JNI 目录和其中的所有文件。

  15. 现在点击底部的确定。

Now you can edit and save in your c files and it will compile and create the .so file on the fly.

现在您可以编辑并保存在您的 c 文件中,它会即时编译和创建 .so 文件。

回答by Deepscorn

Maybe, your development IDE hides system PATH and uses it's own PATH. I had same problem with MOTODEV Eclipse for Android 3.1. Detailed solution is here: How to solve problem with Motodev Eclipse for Android 3.1: wrong PATH It is for MOTODEV IDE, but Eclipse may have same thing.

也许,您的开发 IDE 隐藏了系统 PATH 并使用它自己的 PATH。我在 Android 3.1 的 MOTODEV Eclipse 上遇到了同样的问题。详细解决方案在这里:How to solve problem with Motodev Eclipse for Android 3.1: wrong PATH它是针对MOTODEV IDE的,但Eclipse可能有同样的问题。