Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error:Error occurred while communicating with CMake server

Tags:

c++

android

cmake

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!

like image 576
Roberto Beraldi Avatar asked Nov 20 '17 14:11

Roberto Beraldi


3 Answers

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" ==]
like image 136
gagou7 Avatar answered Nov 02 '22 11:11

gagou7


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

like image 4
kevvex Avatar answered Nov 02 '22 11:11

kevvex


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.

like image 3
zqcolor Avatar answered Nov 02 '22 11:11

zqcolor