Java 外部原生构建问题 Android Studio NDK 示例 HelloJni(构建失败)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/41536040/
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
External Native Build Issues Android Studio NDK Sample HelloJni (Build Failed)
提问by Gunjan Dave
Error: executing external native build for cmake C:\Users\PC1\Desktop\ndkdata\GDNdkText\app\CMakeLists.txt
错误:为 cmake C:\Users\PC1\Desktop\ndkdata\GDNdkText\app\CMakeLists.txt 执行外部本机构建
Error While Building:
构建时出错:
I have installed NDK, CMake, LLDP as mentioned here. Do I need to install any other tool or need to set any environment variables?
我已经安装了这里提到的 NDK、CMake、LLDP 。我是否需要安装任何其他工具或需要设置任何环境变量?
回答by krsoni
You also need to install ncurses5
(for arch-linux its AUR package - ncurses5-compat-libs
), since NDK support on Android Studio 2.2 doesn't use ncurses6 which might be installed on your system.
您还需要安装ncurses5
(对于 arch-linux,其 AUR 包 - ncurses5-compat-libs
),因为 Android Studio 2.2 上的 NDK 支持不使用可能已安装在您的系统上的 ncurses6。
回答by 0xAliHn
I think the problem is the wrong location of CMakelist.txt file.
我认为问题是 CMakelist.txt 文件的位置错误。
Try to move CMakelist.txt file from your app root directory to app/src/main/cpp/CMakelist.txt directory and then update the location from gradle file also like this:
尝试将 CMakelist.txt 文件从您的应用程序根目录移动到 app/src/main/cpp/CMakelist.txt 目录,然后从 gradle 文件更新位置,也如下所示:
externalNativeBuild {
cmake {
path "src/main/cpp/CMakeLists.txt"
}
}
回答by mohamed ossama
If you want to make your project without including any C++ files make sure that you did not check the box that say include C++ in the beginning of new project
如果你想让你的项目不包含任何 C++ 文件,请确保你没有选中在新项目开始时包含 C++ 的框
回答by ariel
If you run under Linux you need to install Ninja. sudo apt install ninja-build
如果在 Linux 下运行,则需要安装 Ninja。sudo apt 安装忍者构建
Tested today.
今天测试了。
回答by Neil Ruggiero
I ran into this issue when importing a co-workers workspace. We were getting external native build errors. And it seemed like the IDE was ignoring a lot of the CMake commands.
我在导入同事工作区时遇到了这个问题。我们收到外部本机构建错误。IDE 似乎忽略了很多 CMake 命令。
It turns out the issue was that I didn't have Ninja installed as suggest in ariel's post above. I discovered this by running gradlew build --stacktrace
and found a line complaining about not having Ninja installed. Note: we are developing in a linux environment.
事实证明,问题是我没有按照上面 ariel 帖子中的建议安装 Ninja。我通过运行gradlew build --stacktrace
发现了这一点,并发现一行抱怨没有安装 Ninja。注意:我们是在linux环境下开发的。
Ninja is a build system that focuses on speed, and is used to replace make
in systems with a large number of input files. Ninja Wiki
Ninja 是一个注重速度的构建系统,用于make
在有大量输入文件的系统中进行替换。 忍者维基
Once I installed ninja, everything build perfectly!
一旦我安装了忍者,一切都完美无缺!
回答by InKwon James Kim
you have to install ninja using homebrew
你必须使用自制软件安装忍者
brew install ninja
回答by ?lker El?ora
I solved my problem with examining log files.
我通过检查日志文件解决了我的问题。
./app/.cxx/cmake/commonDebug/x86/android_gradle_generate_cmake_ninja_json_x86.stderr.txt