Unable to find CMake in Android Studio

后端 未结 13 1039
暖寄归人
暖寄归人 2020-12-07 22:37

I need to add C/C++ code in my Android program for which I needed LLDB, CMake, and NDK. I found LLDB and NDK in SDK manager, but CMake is missing from there. I tried manuall

相关标签:
13条回答
  • 2020-12-07 22:50

    For me, mac OS Android studio. in File->Project Structure-> Project, I changed Gradle version to 4.4 and Android plugin version to 3.1.0, then it gets good.

    Plus, you can also change Android plugin version in gradle-> classpath 'com.android.tools.build:gradle:3.1.0'

    0 讨论(0)
  • 2020-12-07 22:51

    In my case (Android Studio 3.0), there was no CMake in the "SDK Tools" tab in "Appearance & Behaviour -> System Settings -> Android SDK" options. However I noticed that in the "SDK Update sites" tab, there are only two entries, one of which (Android Repository https://dl.google.com/android/repository/repository2-1.xml) had a red mark in the "enabled" column. It read "error 407" on mouseover, which is a proxy authentication error. I had the correct proxy settings (test connection worked fine with the same repository URL), so this was very strange. Restarting android studio didn't help. So I added a new entry with the same repository and this time it worked fine and CMake appeared in the other tab. Hope this helps someone.

    0 讨论(0)
  • 2020-12-07 22:52

    Check this, I think this site explains what you need:

    https://codelabs.developers.google.com/codelabs/android-studio-cmake/index.html?index=..%2F..%2Findex#0

    Remember to check the "What you'll need"

    Update:

    NDK: https://developer.android.com/ndk/downloads/index.html source: https://developer.android.com/ndk/index.html

    CMake: https://cmake.org/files/v3.7/cmake-3.7.1-win64-x64.zip source: https://cmake.org/

    LLDB (Just for Debian systems): http://apt.llvm.org/ source: http://lldb.llvm.org/download.html

    Once you download these files, copy to your SDK folder (normally in: "C:\android-sdk\") You can localize the folder here:

    1. File -> project Structure into Project Structure
    2. Left -> SDK Location

    Then you can continue with the previous guide after the downloads :)

    0 讨论(0)
  • 2020-12-07 22:55
    • Open SDK Manager
    • Switch to the SDK Tools tab
    • Install CMake

    0 讨论(0)
  • 2020-12-07 22:55

    For me what solved as taking off the "version" option in my gradle

     externalNativeBuild {
            cmake {
                path "src/main/cpp/CMakeLists.txt"
                //version was here
            }
        }
    
    0 讨论(0)
  • 2020-12-07 22:56

    place path of the module where your cmake is exist

    if your cmake exist in app main

     externalNativeBuild {
                    cmake {
                            path "CMakeLists.txt"
                          }
                }
    

    if your cmake exist in any module

      externalNativeBuild {
                    cmake {
                        path file('../modulelib/CMakeLists.txt')
                    }
                }
    

    where "modulelib" is your library module folder name

    0 讨论(0)
提交回复
热议问题