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

查看:87
本文介绍了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吗?因为当我在Terminal中运行它时,我一点都没有问题,在这里它告诉我不良的退出价值.

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.

只需提一下我在优胜美地的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天全站免登陆