问题
In Android Studio I'm getting the following error when attempting to build my project:
Error computing CMake server result.
Check for working C compiler: /Users/donturner/Library/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang
Check for working C compiler: /Users/donturner/Library/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang -- works
Detecting C compiler ABI info
Detecting C compiler ABI info - done
Detecting C compile features
Detecting C compile features - done
Check for working CXX compiler: /Users/donturner/Library/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++
Check for working CXX compiler: /Users/donturner/Library/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ -- works
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Detecting CXX compile features
Detecting CXX compile features - done
Configuring done
What is causing this error and how can I resolve it?
回答1:
Android Studio hides the root cause of this error pretty well. To find it you need to open the Build view (View->Tool windows->Build). Now click on the "Toggle windows" button which looks like this:
You should now see the root cause of this problem. In my case it was:
CMake Error at /Users/donturner/Code/workspace-android/io-2019-sonic-boom/SonicBoomApp/app/src/main/cpp/CMakeLists.txt:4 (add_library): Cannot find source file:
src/main/cpp/native-lib.cpp
Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp .hxx .in .txx Failed to compute build system.
FAILURE: Build failed with an exception.
I had an incorrect path to my source file - an easy fix once you know what the problem is.
来源:https://stackoverflow.com/questions/55476461/error-computing-cmake-server-result-in-android-studio