Unable to find CMake in Android Studio

97,688

Solution 1

  • Open SDK Manager
  • Switch to the SDK Tools tab
  • Install CMake

Example Image

Solution 2

If you do the following you may get CMake without any problems:

  1. Open the Settings (Android Studio);
  2. Search by "Android SDK";
  3. On the right side, go to the "SDK Tools" pallet|tab;
  4. Check the "CMake" item on the list;
  5. Press OK button;
  6. Now, just wait the next century while Gradle builds, =D .

Solution 3

  1. Check in your build.gradle file for your App's module

    externalNativeBuild {
        cmake {
            path "CMakeLists.txt"
        }
    }
    
  2. Remove the cmake section

  3. Re-synchronise the project: go to menu Build -> Refersh Lined C++ Projects

  4. Right-click on the module, such as the app module, select "Link C++ Project with Gradle" from the menu.

  5. You should see a dialog similar to the one shown in below figure.

    Enter image description here

  6. Click OK.

Solution 4

  • Go to Android SDK manager
  • Select Android SDK Tools
  • Find CMake and click Apply to download.
  • Later click OK Instructions

Solution 5

Actually, I'm not sure if my solution will be relevant, I will leave it here anyways

go to /Users/yournamehere/Library/Android/sdk/ndk I found the version 21.4.7075529 and deleted it, and then downloaded the same version again using android studio from configuration > Preferences and follow the steps in the attached imageenter image description here

Share:
97,688

Related videos on Youtube

ashish mishra
Author by

ashish mishra

Updated on July 08, 2022

Comments

  • ashish mishra
    ashish mishra almost 2 years

    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 manually downloading it from the CMake official site and found out that for Android we need SDK customized CMake.

    Enter image description here

    As you can see there is no option such as CMake.

    Where do I find a version of CMake for Android?

    I have tried CMake from the website and one I found in ndk-bundle/build folder, but both are giving the same error as below. What can be made out of it and how can the issue be solved?

    Build command failed.
    
    Error while executing 'C:\Users\amishr33\AppData\Local\Android\sdk\cmake\bin\cmake.exe' with arguments {-HC:\Users\amishr33\AndroidStudioProjects\MyApplication\app\src\main\jni -BC:\Users\amishr33\AndroidStudioProjects\MyApplication\app\.externalNativeBuild\cmake\debug\armeabi -GAndroid Gradle - Ninja -DANDROID_ABI=armeabi -DANDROID_NDK=C:\Users\amishr33\AppData\Local\Android\sdk\ndk-bundle -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\amishr33\AndroidStudioProjects\MyApplication\app\build\intermediates\cmake\debug\obj\armeabi -DCMAKE_BUILD_TYPE=Debug -DCMAKE_MAKE_PROGRAM=C:\Users\amishr33\AppData\Local\Android\sdk\cmake\bin\ninja.exe -DCMAKE_TOOLCHAIN_FILE=C:\Users\amishr33\AppData\Local\Android\sdk\ndk-bundle\build\cmake\android.toolchain.cmake -DANDROID_NATIVE_API_LEVEL=15 -DCMAKE_CXX_FLAGS=-std=c++11 -DANDROID_TOOLCHAIN=clang -DANDROID_STL=gnustl_static}
    CMake Error: Could not create named generator Android Gradle - Ninja
    Generators
      Visual Studio 15 2017 [arch] = Generates Visual Studio 2017 project files.
                                     Optional [arch] can be "Win64" or "ARM".
      Visual Studio 14 2015 [arch] = Generates Visual Studio 2015 project files.
                                     Optional [arch] can be "Win64" or "ARM".
      Visual Studio 12 2013 [arch] = Generates Visual Studio 2013 project files.
                                     Optional [arch] can be "Win64" or "ARM".
      Visual Studio 11 2012 [arch] = Generates Visual Studio 2012 project files.
                                     Optional [arch] can be "Win64" or "ARM".
      Visual Studio 10 2010 [arch] = Generates Visual Studio 2010 project files.
                                     Optional [arch] can be "Win64" or "IA64".
      Visual Studio 9 2008 [arch]  = Generates Visual Studio 2008 project files.
                                     Optional [arch] can be "Win64" or "IA64".
      Visual Studio 8 2005 [arch]  = Generates Visual Studio 2005 project files.
                                     Optional [arch] can be "Win64".
      Visual Studio 7 .NET 2003    = Deprecated.  Generates Visual Studio .NET
                                     2003 project files.
      Borland Makefiles            = Generates Borland makefiles.
      NMake Makefiles              = Generates NMake makefiles.
      NMake Makefiles JOM          = Generates JOM makefiles.
      Green Hills MULTI            = Generates Green Hills MULTI files
                                     (experimental, work-in-progress).
      MSYS Makefiles               = Generates MSYS makefiles.
      MinGW Makefiles              = Generates a make file for use with
                                     mingw32-make.
      Unix Makefiles               = Generates standard UNIX makefiles.
      Ninja                        = Generates build.ninja files.
      Watcom WMake                 = Generates Watcom WMake makefiles.
      CodeBlocks - MinGW Makefiles = Generates CodeBlocks project files.
      CodeBlocks - NMake Makefiles = Generates CodeBlocks project files.
      CodeBlocks - Ninja           = Generates CodeBlocks project files.
      CodeBlocks - Unix Makefiles  = Generates CodeBlocks project files.
      CodeLite - MinGW Makefiles   = Generates CodeLite project files.
      CodeLite - NMake Makefiles   = Generates CodeLite project files.
      CodeLite - Ninja             = Generates CodeLite project files.
      CodeLite - Unix Makefiles    = Generates CodeLite project files.
      Sublime Text 2 - MinGW Makefiles
                                   = Generates Sublime Text 2 project files.
      Sublime Text 2 - NMake Makefiles
                                   = Generates Sublime Text 2 project files.
      Sublime Text 2 - Ninja       = Generates Sublime Text 2 project files.
      Sublime Text 2 - Unix Makefiles
                                   = Generates Sublime Text 2 project files.
      Kate - MinGW Makefiles       = Generates Kate project files.
      Kate - NMake Makefiles       = Generates Kate project files.
      Kate - Ninja                 = Generates Kate project files.
      Kate - Unix Makefiles        = Generates Kate project files.
      Eclipse CDT4 - NMake Makefiles
                                   = Generates Eclipse CDT 4.0 project files.
      Eclipse CDT4 - MinGW Makefiles
                                   = Generates Eclipse CDT 4.0 project files.
      Eclipse CDT4 - Ninja         = Generates Eclipse CDT 4.0 project files.
      Eclipse CDT4 - Unix Makefiles= Generates Eclipse CDT 4.0 project files.
    Error:executing external native build for cmake C:\Users\amishr33\AndroidStudioProjects\MyApplication\app\src\main\jni\CMakeLists.txt
    
    • Alberto
      Alberto over 7 years
      Which version of Android studio are u using? Try to update to the lastest, I tried to update my android Studio to 2.2.3 and inside Android SDK --> SDK Tools it appears to me as u can see here: screenshot I hope i helped u m8 :D Sorry for answering a bit late :(
    • Jon Goodwin
      Jon Goodwin over 7 years
      Are you using 32 bit windows ? Android Studio Cmake only works on 64 bit machines. That's why you could not find Cmake in the SDK manager .
    • user1453328
      user1453328 over 6 years
      make sure you are using 64 bit Android Studio! See this stackoverflow.com/questions/42912919/…
    • MNFS
      MNFS over 6 years
      have u solved the problem?
    • Jeremy Clarkson
      Jeremy Clarkson about 6 years
      you can install it in sdk manager tools, but first you must close your project
    • ashish mishra
      ashish mishra about 6 years
      I updated the version Android studio..and found cmake in SDK tools @MNFS
    • user13267
      user13267 about 5 years
      Why do all these answers have so many upvotes?
    • user13267
      user13267 about 5 years
      The question clearly says the problem is Cmake is not present in the list, and non of thew answers give a solution to this problem, or say it is happening
  • ashish mishra
    ashish mishra over 7 years
    but it doesn't tell how/where to get CMake for android studio.
  • Alberto
    Alberto over 7 years
    You are searching the "download" section?
  • Alberto
    Alberto over 7 years
    Check this link: developer.android.com/studio/projects/add-native-code.html If u have any problem, make me know it and I'll be happy to help u :D
  • ashish mishra
    ashish mishra over 7 years
    download section asks to open SDK manager and download CMake from their... but there is no CMake option in SDK manager.
  • Alberto
    Alberto over 7 years
    @ashishmishra Check the update of the answer, i think that's what u need.
  • ashish mishra
    ashish mishra over 7 years
    I have already tried that part, downloading cmake manually from its website and saving it in sdk folder. but it does not work. I n my research on this issue i found that SDK uses a specifically customised CMake for android, I am trying to find that version of CMake.
  • AnilV
    AnilV over 6 years
    Thanks Girish. This is the best way to fix it and it worked for me!!
  • MNFS
    MNFS over 6 years
    i think the question is about no CMake in SDK Tools
  • Vlad
    Vlad about 6 years
    There in no item Refersh Lined C++ Projects in as3 menu
  • mondaugen
    mondaugen about 6 years
    Why is this in "Appearance & Behavior"?
  • Innocent
    Innocent over 5 years
    Thank you but I have a problem in cMakeList.txt set_target_properties error can you please help me
  • Siddhpura Amit
    Siddhpura Amit over 5 years
    Thank you so much, it saved my lots of time
  • XFMoulet
    XFMoulet over 3 years
    I think the issue is that no CMake is showing on the menu
  • karl
    karl over 3 years
    Not sure why this was down voted, worked for me, since my cmake was more recent than the one asked for. My up vote makes it 0 I guess :), but for Linux Mint folks, this answer is good. You'll also need to install ninja-build.
  • Peter
    Peter over 2 years
    For anyone who got here because they did not have a particular version of CMake (for me it was CMake '3.10.2' was not found in SDK, PATH, or by cmake.dir property. ) Click the "Show Package Details" box in bottom right to allow you to download the particular version.