我需要在我的Android程序中添加C / C ++代码,我需要LLDB,CMake和NDK。我在SDK管理器中找到了LLDB和NDK,但那里缺少CMake。我尝试从CMake官方网站手动下载它,发现对于Android我们需要SDK定制的CMake。
正如您所看到的,没有像CMake这样的选项。
我在哪里可以找到适用于Android的CMake版本?
我在网站上尝试过CMake,在ndk-bundle / build文件夹中找到了一个,但两者都给出了如下错误。可以做些什么以及如何解决问题?
Build command failed.
Error while executing 'C:\Users\amishr33\AppData\Local\Android\sdk\cmake\bin\cmake.exe' with arguments {-HC:\Users\amishr33\AndroidStudioProjects\MyApplication\app\src\main\jni -BC:\Users\amishr33\AndroidStudioProjects\MyApplication\app\.externalNativeBuild\cmake\debug\armeabi -GAndroid Gradle - Ninja -DANDROID_ABI=armeabi -DANDROID_NDK=C:\Users\amishr33\AppData\Local\Android\sdk\ndk-bundle -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\amishr33\AndroidStudioProjects\MyApplication\app\build\intermediates\cmake\debug\obj\armeabi -DCMAKE_BUILD_TYPE=Debug -DCMAKE_MAKE_PROGRAM=C:\Users\amishr33\AppData\Local\Android\sdk\cmake\bin\ninja.exe -DCMAKE_TOOLCHAIN_FILE=C:\Users\amishr33\AppData\Local\Android\sdk\ndk-bundle\build\cmake\android.toolchain.cmake -DANDROID_NATIVE_API_LEVEL=15 -DCMAKE_CXX_FLAGS=-std=c++11 -DANDROID_TOOLCHAIN=clang -DANDROID_STL=gnustl_static}
CMake Error: Could not create named generator Android Gradle - Ninja
Generators
Visual Studio 15 2017 [arch] = Generates Visual Studio 2017 project files.
Optional [arch] can be "Win64" or "ARM".
Visual Studio 14 2015 [arch] = Generates Visual Studio 2015 project files.
Optional [arch] can be "Win64" or "ARM".
Visual Studio 12 2013 [arch] = Generates Visual Studio 2013 project files.
Optional [arch] can be "Win64" or "ARM".
Visual Studio 11 2012 [arch] = Generates Visual Studio 2012 project files.
Optional [arch] can be "Win64" or "ARM".
Visual Studio 10 2010 [arch] = Generates Visual Studio 2010 project files.
Optional [arch] can be "Win64" or "IA64".
Visual Studio 9 2008 [arch] = Generates Visual Studio 2008 project files.
Optional [arch] can be "Win64" or "IA64".
Visual Studio 8 2005 [arch] = Generates Visual Studio 2005 project files.
Optional [arch] can be "Win64".
Visual Studio 7 .NET 2003 = Deprecated. Generates Visual Studio .NET
2003 project files.
Borland Makefiles = Generates Borland makefiles.
NMake Makefiles = Generates NMake makefiles.
NMake Makefiles JOM = Generates JOM makefiles.
Green Hills MULTI = Generates Green Hills MULTI files
(experimental, work-in-progress).
MSYS Makefiles = Generates MSYS makefiles.
MinGW Makefiles = Generates a make file for use with
mingw32-make.
Unix Makefiles = Generates standard UNIX makefiles.
Ninja = Generates build.ninja files.
Watcom WMake = Generates Watcom WMake makefiles.
CodeBlocks - MinGW Makefiles = Generates CodeBlocks project files.
CodeBlocks - NMake Makefiles = Generates CodeBlocks project files.
CodeBlocks - Ninja = Generates CodeBlocks project files.
CodeBlocks - Unix Makefiles = Generates CodeBlocks project files.
CodeLite - MinGW Makefiles = Generates CodeLite project files.
CodeLite - NMake Makefiles = Generates CodeLite project files.
CodeLite - Ninja = Generates CodeLite project files.
CodeLite - Unix Makefiles = Generates CodeLite project files.
Sublime Text 2 - MinGW Makefiles
= Generates Sublime Text 2 project files.
Sublime Text 2 - NMake Makefiles
= Generates Sublime Text 2 project files.
Sublime Text 2 - Ninja = Generates Sublime Text 2 project files.
Sublime Text 2 - Unix Makefiles
= Generates Sublime Text 2 project files.
Kate - MinGW Makefiles = Generates Kate project files.
Kate - NMake Makefiles = Generates Kate project files.
Kate - Ninja = Generates Kate project files.
Kate - Unix Makefiles = Generates Kate project files.
Eclipse CDT4 - NMake Makefiles
= Generates Eclipse CDT 4.0 project files.
Eclipse CDT4 - MinGW Makefiles
= Generates Eclipse CDT 4.0 project files.
Eclipse CDT4 - Ninja = Generates Eclipse CDT 4.0 project files.
Eclipse CDT4 - Unix Makefiles= Generates Eclipse CDT 4.0 project files.
Error:executing external native build for cmake C:\Users\amishr33\AndroidStudioProjects\MyApplication\app\src\main\jni\CMakeLists.txt
答案 0 :(得分:108)
答案 1 :(得分:26)
如果您执行以下操作,您可能会毫无问题地获得CMake:
答案 2 :(得分:10)
答案 3 :(得分:8)
答案 4 :(得分:1)
就我而言(Android Studio 3.0)," SDK工具"中没有CMake。选项卡"外观&行为 - >系统设置 - > Android SDK"选项。但是我注意到在" SDK更新站点"选项卡,只有两个条目,其中一个(Android Repository https://dl.google.com/android/repository/repository2-1.xml)在"启用"中有一个红色标记。柱。它读了"错误407"在mouseover上,这是一个代理身份验证错误。我有正确的代理设置(测试连接与相同的存储库URL工作正常),所以这很奇怪。重启android studio并没有帮助。所以我添加了一个具有相同存储库的新条目,这次它工作正常,CMake出现在另一个选项卡中。希望这有助于某人。
答案 5 :(得分:1)
您可以在SDK Manager工具中安装它,但首先必须关闭已打开的项目。在开始菜单上使用配置。
答案 6 :(得分:1)
答案 7 :(得分:1)
检查您是否使用64位版本的Android Studio。在Android Studio 32位中,CMake不会出现在SDK Manager中。
答案 8 :(得分:0)
检查一下,我认为这个网站解释了你的需求:
请务必查看"您需要的内容"
NDK:https://developer.android.com/ndk/downloads/index.html 来源:https://developer.android.com/ndk/index.html
CMake:https://cmake.org/files/v3.7/cmake-3.7.1-win64-x64.zip 来源:https://cmake.org/
LLDB(仅适用于Debian系统):http://apt.llvm.org/ 来源:http://lldb.llvm.org/download.html
下载这些文件后,请复制到SDK文件夹(通常位于:" C:\ android-sdk \") 您可以在此处本地化文件夹:
然后,您可以在下载后继续使用上一个指南:)
答案 9 :(得分:0)
在我改变CMake path
工作的情况下:
externalNativeBuild {
/*
cmake {
path "CMakeLists.txt"
}
*/
cmake {
path 'src/main/jni/opus/CMakeLists.txt'
}
}
答案 10 :(得分:0)
对我来说,是Mac OS Android Studio。在“文件”->“项目结构”->“项目”中,我将Gradle版本更改为4.4,将Android插件版本更改为3.1.0,
此外,您还可以在gradle-> classpath'com.android.tools.build:gradle:3.1.0'中更改Android插件版本
答案 11 :(得分:0)
放置cmake的模块的放置路径
如果您的cmake存在于应用程序主窗口中
externalNativeBuild {
cmake {
path "CMakeLists.txt"
}
}
如果您的cmake存在于任何模块中
externalNativeBuild {
cmake {
path file('../modulelib/CMakeLists.txt')
}
}
其中“ modulelib”是您的库模块文件夹名称
答案 12 :(得分:0)
对我来说,解决我在gradle中取消“版本”选项的问题
externalNativeBuild {
cmake {
path "src/main/cpp/CMakeLists.txt"
//version was here
}
}
答案 13 :(得分:0)
我在 Android Studio 4.2 C15 上使用 SDK 30 以及 OpenCV 4 和 Ninja,在我的情况下,更改 CMake 路径如下所示:
externalNativeBuild {
/*
cmake {
path "CMakeLists.txt"
}
*/
cmake {
path (project.projectDir.toString() + '/libcxx_helper/CMakeLists.txt')
}
}