Android Studio CMake Error: Build Command failed Android Studio CMake Error: Build Command failed android android

Android Studio CMake Error: Build Command failed


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


I found this Solution Online and this worked, however there was no explanation on how it worked:Remove the following block of code from you build.gradle file:

externalNativeBuild {    cmake {        path "src/main/cpp/CMakeLists.txt"    }}


@rpurohit was nearly right, Clang isn't working properly. But to change the Compiler you need to change build.gradle, in my build.gradle it was Line 12:

apply plugin: 'com.android.application'1 android {2    compileSdkVersion 253    buildToolsVersion '25.0.2'4    defaultConfig {5       applicationId 'com.example.hellojni'6       minSdkVersion 237       targetSdkVersion 258       versionCode 19       versionName "1.0"10      externalNativeBuild {11          cmake {12              arguments '-DANDROID_TOOLCHAIN=clang' --> gcc            }        }    }    buildTypes {        release {            minifyEnabled false            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'        }    }    externalNativeBuild {        cmake {            path "src/main/cpp/CMakeLists.txt"        }    }    productFlavors {        arm7 {            // in the future, ndk.abiFilter might also work            ndk {                abiFilter 'armeabi-v7a'            }        }        arm8 {            ndk {                abiFilters 'arm64-v8a'            }        }        arm {            ndk {                abiFilter 'armeabi'            }        }        x86 {            ndk {                abiFilter 'x86'            }        }        x86_64 {            ndk {                abiFilter 'x86_64'            }        }        mips {            ndk {                abiFilters 'mips', 'mips64'            }        }        universal {            ndk {                abiFilters 'mips', 'mips64', 'x86', 'x86_64'            }        }    }}dependencies {    compile fileTree(dir: 'libs', include: ['*.jar'])    compile 'com.android.support:appcompat-v7:25.2.0'    compile 'com.android.support.constraint:constraint-layout:1.0.1'}