我正在使用Android Studio 3.1.1创建一个具有c ++支持的新项目,但我却无能为力,并且同步失败,消息如下:
Build command failed.
Error while executing process E:\AndroidSDK\adt-bundle-windows-x86_64-20140702\adt-bundle-windows-x86_64-20140702\sdk\cmake\3.6.4111459\bin\cmake.exe with arguments {-HF:\ASworkspace\TestJniApplication\app\src\main\cpp -BF:\ASworkspace\TestJniApplication\app\.externalNativeBuild\cmake\release\armeabi-v7a -DANDROID_ABI=armeabi-v7a -DANDROID_PLATFORM=android-19 -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=F:\ASworkspace\TestJniApplication\app\build\intermediates\cmake\release\obj\armeabi-v7a -DCMAKE_BUILD_TYPE=Release -DANDROID_NDK=E:\AndroidSDK\adt-bundle-windows-x86_64-20140702\adt-bundle-windows-x86_64-20140702\sdk\ndk-bundle -DCMAKE_CXX_FLAGS= -DCMAKE_TOOLCHAIN_FILE=E:\AndroidSDK\adt-bundle-windows-x86_64-20140702\adt-bundle-windows-x86_64-20140702\sdk\ndk-bundle\build\cmake\android.toolchain.cmake -DCMAKE_MAKE_PROGRAM=E:\AndroidSDK\adt-bundle-windows-x86_64-20140702\adt-bundle-windows-x86_64-20140702\sdk\cmake\3.6.4111459\bin\ninja.exe -GAndroid Gradle - Ninja}
-- Check for working C compiler: E:/AndroidSDK/adt-bundle-windows-x86_64-20140702/adt-bundle-windows-x86_64-20140702/sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe
-- Check for working C compiler: E:/AndroidSDK/adt-bundle-windows-x86_64-20140702/adt-bundle-windows-x86_64-20140702/sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe -- broken
/AndroidSDK/adt-bundle-windows-x86_64-20140702/adt-bundle-windows-x86_64-20140702/sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe" is not able to compile a simple test program.
Open File
It fails with the following output:
Change Dir: F:/ASworkspace/TestJniApplication/app/.externalNativeBuild/cmake/release/armeabi-v7a/CMakeFiles/CMakeTmp
Run Build
Command:"E:\AndroidSDK\adt-bundle-windows-x86_64-20140702\adt-bundle-windows-x86_64-20140702\sdk\cmake\3.6.4111459\bin\ninja.exe"
"cmTC_bc909"
[1/2] Building C object CMakeFiles/cmTC_bc909.dir/testCCompiler.c.o
[2/2] Linking C executable cmTC_bc909
FAILED: cmd.exe /C "cd . &&
E:\AndroidSDK\adt-bundle-windows-x86_64-20140702\adt-bundle-windows-x86_64-20140702\sdk\ndk-bundle\toolchains\llvm\prebuilt\windows-x86_64\bin\clang.exe
--target=armv7-none-linux-androideabi
--gcc-toolchain=E:/AndroidSDK/adt-bundle-windows-x86_64-20140702/adt-bundle-windows-x86_64-20140702/sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64
--sysroot=E:/AndroidSDK/adt-bundle-windows-x86_64-20140702/adt-bundle-windows-x86_64-20140702/sdk/ndk-bundle/sysroot
-isystem
E:/AndroidSDK/adt-bundle-windows-x86_64-20140702/adt-bundle-windows-x86_64-20140702/sdk/ndk-bundle/sysroot/usr/include/arm-linux-androideabi
-D__ANDROID_API__=19 -g -DANDROID -ffunction-sections -funwind-tables
-fstack-protector-strong -no-canonical-pre-- Configuring incomplete,fixes -march=armv7-a
errors occurred!
-mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -Wa,--noexecstack -Wformat
sdk是最新的,
然后gradle版本是3.1.3。我对此一无所知,有人可以帮我吗? 谢谢。
答案 0 :(得分:0)
adt-bundle-windows-x86_64-20140702
对于Android Studio而言太旧了。不知道为什么您的项目仍使用此旧工具链。
只需删除此ADT捆绑包(该捆绑包于2014年发布,但由于版本太旧而无法与Android Studio 3.1.3兼容)。只需下载最新的Android Studio并使用内置的SDK和NDK捆绑包即可正常运行。
您可以在项目根目录下的local.properties
中再次检查 ndk 和 sdk 设置,它应该类似于
ndk.dir=<your-ndk-root-dir>
sdk.dir=<your-sdk-root-dir>