Android Studio CMake Error: Build Command failed

前端 未结 9 1411
孤独总比滥情好
孤独总比滥情好 2020-12-15 20:21

I\'m running into an Error when I open a new project in Android Studio from the Code Samples (Hello JIN). When the Project is opened the following:

Build com         


        
相关标签:
9条回答
  • 2020-12-15 20:58

    Build -> Refresh Linked C++ Projects resolved this error for me.

    0 讨论(0)
  • 2020-12-15 21:00

    I would recommend using GCC instead of clang for the time being because clang still does not contain all features. You can change your compiler by doing the following:

    set(CMAKE_C_COMPILER /path-to-ndk/toolchains/aarch64-linux-android-4.9/prebuilt/darwin-x86_64/bin/aarch64-linux-android-gcc)
    

    However, the darwin-x86_64 directory only exists if you are on a Mac. If you are on another platform, just use the directory that exists under the prebuilt folder.

    0 讨论(0)
  • 2020-12-15 21:01

    I encountered this problem because I set the wrong path of native-lib.cpp. After changing

    add_library(native-lib SHARED native-lib.cpp)
    

    to

    add_library(native-lib SHARED src/main/jni/native-lib.cpp)
    

    it worked again.

    By the way, this is part of my project's structure.

    CMakeLists.txt
    src
     |__main
          |___jni
               |___native-lib.cpp
    
    0 讨论(0)
提交回复
热议问题