Android Studio 2.3.3的Windows 10操作系统。
我尝试使用JNI将现有C++项目链接到Android Studio。我还尝试加载提供的所有NDK-JNI示例项目。使用JNI/Cmake的所有项目都无法进行Gradle Sync,失败时出现相同的错误:
Build command failed.
Error while executing process C:\Users\Alex\AppData\Local\Android\Sdk\cmake\3.6.3155560\bin\cmake.exe with arguments {-HC:\Users\Alex\Desktop\android-ndk\hello-jni\app\src\main\cpp -BC:\Users\Alex\Desktop\android-ndk\hello-jni\app\.externalNativeBuild\cmake\armDebug\armeabi -GAndroid Gradle - Ninja -DANDROID_ABI=armeabi -DANDROID_NDK=C:\Users\Alex\AppData\Local\Android\Sdk\ndk-bundle -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\Alex\Desktop\android-ndk\hello-jni\app\build\intermediates\cmake\arm\debug\obj\armeabi -DCMAKE_BUILD_TYPE=Debug -DCMAKE_MAKE_PROGRAM=C:\Users\Alex\AppData\Local\Android\Sdk\cmake\3.6.3155560\bin\ninja.exe -DCMAKE_TOOLCHAIN_FILE=C:\Users\Alex\AppData\Local\Android\Sdk\ndk-bundle\build\cmake\android.toolchain.cmake -DANDROID_PLATFORM=android-23 -DANDROID_TOOLCHAIN=clang}
-- Check for working C compiler: C:/Users/Alex/AppData/Local/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe
-- Check for working C compiler: C:/Users/Alex/AppData/Local/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe -- broken
CMake Error at C:/Users/Alex/AppData/Local/Android/sdk/cmake/3.6.3155560/share/cmake-3.6/Modules/CMakeTestCCompiler.cmake:61 (message):
The C compiler
"C:/Users/Alex/AppData/Local/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: C:/Users/Alex/Desktop/android-ndk/hello-jni/app/.externalNativeBuild/cmake/armDebug/armeabi/CMakeFiles/CMakeTmp
Run Build
Command:"C:\Users\Alex\AppData\Local\Android\Sdk\cmake\3.6.3155560\bin\ninja.exe"
"cmTC_accda"
[1/2] Building C object CMakeFiles/cmTC_accda.dir/testCCompiler.c.o
[2/2] Linking C executable cmTC_accda
FAILED: cmd.exe /C "cd . &&
C:\Users\Alex\AppData\Local\Android\sdk\ndk-bundle\toolchains\llvm\prebuilt\windows-x86_64\bin\clang.exe
--target=armv5te-none-linux-androideabi
--gcc-toolchain=C:/Users/Alex/AppData/Local/Android/sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64
--sysroot=C:/Users/Alex/AppData/Local/Android/sdk/ndk-bundle/sysroot
-isystem
C:/Users/Alex/AppData/Local/Android/sdk/ndk-bundle/sysroot/usr/include/arm-linux-androideabi
-D__ANDROID_API__=23 -g -DANDROID -ffunction-sections -funwind-tables
-fstack-protector-strong -no-canonical-prefixes -march=armv5te
-Werror=format-security -Wl,--exclude-libs,libgcc.a --sysroot
C:/Users/Alex/AppData/Local/Android/sdk/ndk-bundle/platforms/android-23/arch-arm64
-Wl,--build-id -Wl,--warn-shared-textrel -Wl,--fatal-warnings
-Wl,--no-undefined -Wl,-z,noexecstack -Qunused-arguments -Wl,-z,relro
-Wl,-z,now -Wl,--gc-sections -Wl,-z,nocopyreloc -pie -fPIE
CMakeFiles/cmTC_f48b1.dir/testCCompiler.c.o -o cmTC_f48b1 -lm && cd ."
The system cannot find the path specified.
ninja: build stopped: subcommand failed.
CMake will not be able to correctly generate this project.
我已经安装了所有必要的SDK工具。我已经尝试使用GCC代替clang。谢谢你的帮助!
2条答案
按热度按时间tnkciper1#
主要的错误消息是:
注意,上面有些地方使用
/
作为路径分隔符:并已成功运行。下面这一行:
似乎失败了。我猜问题出在
\
上。试着找到这个路径是在哪里定义的,也许在IDE选项、配置文件或Makefile中,然后修改它可能会解决问题。rxztt3cl2#
这是因为叮当声版本不匹配检查叮当声版本你有什么最低叮当声版本Android应用程序需要!