18

I'm trying to build a simple native app from Android Studio 3.0 on Windows 10. When I will try to build the app, I get the following error:

"Error:Error occurred while communicating with CMake server. Check log xxx\Native\app.externalNativeBuild\cmake\debug\armeabi-v7a\cmake_server_log.txt for additional information."

And the log contains:

"CMAKE SERVER: CMAKE SERVER: [== "CMake Server" ==[ CMAKE SERVER: {"supportedProtocolVersions":[{"isExperimental":true,"major":1,"minor":1}],"type":"hello"} CMAKE SERVER: ]== "CMake Server" ==]"

I have created the "CMakeLists.txt" as required in the official documenation..

Any suggestions on how to fix this problem? Thank you!

Gnqz
  • 3,292
  • 3
  • 25
  • 35
Roberto Beraldi
  • 181
  • 1
  • 1
  • 3
  • Same problem here, my problem was a manually compiled cmake. Installing cmake from https://stackoverflow.com/questions/41218241/unable-to-find-cmake-in-android-studio fixed it! – Ferenc Deak Dec 01 '17 at 13:02
  • 3
    Seems like AndroidStudio won't work with CMake 3.10 for now. A possible source of the problem is the bump in cmake-server protocol version (to 1.1), but I can't find sources to Google's Adnroid Gradle Plugin to confirm that, and their error log is, at best, vague. – MaxEd Dec 05 '17 at 22:20
  • 1
    Spent a couple of hours trying to get that working, hoping to be able the compile for C++ 17. Downgrading CMake still did not work for whatever reason, though from 3.9.x it seems to pass the server version check. I've decided to keep using C++ 14 together with the CMake 3.6 binaries provided with the NDK and use a backporting of string_view since that's all I needed from C++ 17. – Slion Feb 20 '18 at 16:32

3 Answers3

8

Actually the issue is that Gradle is interpreting the debug output of the cmake-server as an error and fails. It happens with com.android.tools.build:gradle:3.0.0 but it works correctly starting with com.android.tools.build:gradle:3.1.0.

If for some reason (plugin, etc) you cannot update to 3.1.0, you can replace cmake with a python wrapper and filter the output by removing this exact output:

[== "CMake Server" ==[

{"supportedProtocolVersions":[{"isExperimental":true,"major":1,"minor":1}],"type":"hello"}

]== "CMake Server" ==]
gagou7
  • 293
  • 3
  • 12
4

I had the same problem. This worked for me.

Goto the SDK Manager --> Android SDK --> SDK Tools --> CMake.

And install CMake from the SDK manager. Just check the images if you don't get what I mean.

enter image description here

enter image description here

kevvex
  • 305
  • 3
  • 12
  • 3
    Check "Show Package Details" checkbox to see optional versions of every tool, and install/uninstall what fits to you. For me recplacing CMake 3.10.2 with CMake 3.6 did the work. – RanSh Apr 03 '19 at 10:10
  • 3
    Uninstalling CMake 3.10.2 and installing 3.6.4111459 back did the trick for me either. – deko Jul 15 '19 at 06:39
  • 1
    @RanSh Replace CMake 3.10.2 with CMake 3.6 worked for me, thanks! – 一有新人 Aug 30 '19 at 08:06
3

I got exact same error, even with the solution from kevvex, android studio reported same error.

I compared with another working windows 10 machine and found three differences:

  1. CMake is 3.10xxx is not working on my machine, CMake 3.6.4111459 is on working machine

  2. OpenCV-android-sdk version 2.4.7.2 is not working on my machine, OpenCV-android-sdk version 3.2.0 is on working machine

  3. android-ndk/ndk-bundle 14.1.3816874 is not working on my machine, android-ndk/ndk-bundle r15c is on working machine (This one maybe optional)

Replaced these three items, the project is built successfully on my machine.

zqcolor
  • 332
  • 2
  • 4
  • 13