Android Studio 构建 NDK 项目失败,退出值非零 [英] Android Studio failed build NDK project non-zero exit value

查看:43
本文介绍了Android Studio 构建 NDK 项目失败,退出值非零的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将我正在处理的项目从 Eclipse Android SDK 环境导入到新的 Android Studio.尝试运行该项目我得到了这个

I imported a project that I was working on from an Eclipse Android SDK environment to the new Android Studio. Trying to run the project I get this

Error:Execution failed for task ':app:compileDebugNdk'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'ndk/ndk-build'' finished with non-zero exit value 2

所以首先对我来说,看到这个错误很奇怪,因为之前在 Eclipse Android SDK 中工作,我自己运行了 ndk-build,我仍然这样做.那么 Android Studio 现在为我运行 ndk-build 了吗?因为当我在终端中运行它时,我完全没有问题,在这里它告诉我退出值错误.

So first of all for me it's weird to see this error, because working in Eclipse Android SDK before, I ran ndk-build by myself which I still do. So is Android Studio running ndk-build for me now? Because when I run it in Terminal I have no problem at all and here it tells me bad exit-value.

然后我在互联网上搜索并找到了一个快速修复",即创建一个空的 .c 文件,因为您无法在没有 .c 文件的情况下构建/运行 ndk 项目.这并不奇怪,这对我不起作用,因为 .jni 文件夹中有大量 .c 文件.

And then I searched on the internet and found a "quick fix", which is to create an empty .c file, because you can't build/run ndk project with no .c files. This, not surprisingly, does not work for me because we have plenty of .c files in the .jni folder.

顺便提一下,我在 Yosemite 下的 Macbook Pro 上,项目本身应该没有问题.

Just to mention I'm on a Macbook Pro under Yosemite, and the project should have no problems in itself.

在此先感谢您的帮助.

推荐答案

这是 Android Studio 的已知问题,由对启用 NDK 的项目的支持非常有限造成.回答您的问题:是的,Android Studio 现在自己运行 ndk-build,但它会忽略现有的 Android.mk 并动态生成一个(并且对于任何启用 NDK 的重要项目都做错了).实际上,解决此问题的最佳方法是禁用 Android Studio 有限的 NDK 支持并从 gradle 脚本调用 ndk-build.此处我已经更详细地描述了它以及如何修复它.

This is known problem of Android Studio, caused by very limited support of NDK-enabled projects. Answering to your question: yes, Android Studio now run ndk-build on its own, but it ignore existing Android.mk and generate one on the fly (and do it wrong for any non-trivial NDK-enabled project). Practically, the best way to fix this is to disable Android Studio's limited NDK support and call ndk-build from gradle script. Here I've described it more detailed and how to get it fixed.

这篇关于Android Studio 构建 NDK 项目失败,退出值非零的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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