Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error after upgrading Android Studio NDK: CMAKE_C_COMPILER and CMAKE_CXX_COMPILER not set

After updating Android Studio NDK, I can't build my app, due to an error related to CMAKE (my application uses one c++ file). Here are the error lines:

Build command failed.
Error while executing process C:\Users\AnimallTag\AppData\Local\Android\sdk\cmake\3.6.4111459\bin\cmake.exe with arguments {-HC:\Projetos\Git\at65\app -BC:\Projetos\Git\at65\app\.externalNativeBuild\cmake\debug\mips -GAndroid Gradle - Ninja -DANDROID_ABI=mips -DANDROID_NDK=C:\Users\AnimallTag\AppData\Local\Android\sdk\ndk-bundle -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Projetos\Git\at65\app\build\intermediates\cmake\debug\obj\mips -DCMAKE_BUILD_TYPE=Debug -DCMAKE_MAKE_PROGRAM=C:\Users\AnimallTag\AppData\Local\Android\sdk\cmake\3.6.4111459\bin\ninja.exe -DCMAKE_TOOLCHAIN_FILE=C:\Users\AnimallTag\AppData\Local\Android\sdk\ndk-bundle\build\cmake\android.toolchain.cmake -DANDROID_PLATFORM=android-14}
 (include)   CMakeLists.txt 
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!

Any suggestion to help me solve that problem? Maybe a way I can downgrade NDK or a Android Studio previous version I can install...

Error screen in Android Studio

like image 442
Nathan Imamura Avatar asked May 17 '18 21:05

Nathan Imamura


2 Answers

I managed to fix it. One thing I noticed was the changelog of android NDK, and it says there is no more support for armeabi, MIPS and MIPS64 ABIs, so I filtered ABIs in my build.gradle file:

android {
    defaultConfig {
        externalNativeBuild {
            cmake {
                abiFilters 'arm64-v8a', 'armeabi-v7a', 'x86', 'x86_64'
            }
        }
    }
}

After that I synchronized gradle and Android Studio prompted me to update Gradle, and I did. The app can now be deployed, but I'm not sure what fixed it. Apparently the error was not related to CMAKE_C_COMPILER neither CMAKE_CXX_COMPILER, it was happening somewhere else and when the build failed, it wasn't able to find those variables. Maybe this can help someone too...

like image 169
Nathan Imamura Avatar answered Oct 13 '22 01:10

Nathan Imamura


After NDK Recent update CMAKE was breaking

Nothing Worked but I downgraded NDK by downloading NDK from https://developer.android.com/ndk/downloads/older_releases

and changed NDK DIR PATH in local.properties to

ndk.dir=/Users/kathan/Library/Android/sdk/android-ndk-r17c

And just Sync Gradle.

Worked like Charm

like image 26
Kathan Shah Avatar answered Oct 13 '22 01:10

Kathan Shah