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

查看:20
本文介绍了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天全站免登陆