Android ndk error asm types.h not found

In Android studio 3.0 and ndk 15, I got this error too. But I resolved this, but analyse it in chinese.

http://www.jianshu.com/p/27f98165d73d

Method :

if(${ANDROID_ABI} STREQUAL "armeabi-v7a")
    include_directories(${ANDROID_SYSROOT}/usr/include/arm-linux-androideabi)
elseif(${ANDROID_ABI} STREQUAL "arm64-v8a")
    include_directories(${ANDROID_SYSROOT}/usr/include/aarch64-linux-android)
else()
    include_directories(${ANDROID_SYSROOT}/usr/include/arm-linux-androideabi)
endif()

Method 2

SET(CMAKE_CXX_FLAGS "-isystem /home/cc/Android/Sdk/ndk-bundle/sysroot/usr/include/arm-linux-androideabi")

Method 3

include_directories(${ANDROID_SYSROOT}/usr/include/arm-linux-androideabi)


Method one from Lemac's answer works for me with the slight modifications:

if (${ANDROID_ABI} STREQUAL "x86_64")
    include_directories(${ANDROID_SYSROOT}/usr/include/x86_64-linux-android)
elseif (${ANDROID_ABI} STREQUAL "x86")
    include_directories(${ANDROID_SYSROOT}/usr/include/i686-linux-android)
elseif (${ANDROID_ABI} STREQUAL "arm64-v8a")
    include_directories(${ANDROID_SYSROOT}/usr/include/aarch64-linux-android)
elseif (${ANDROID_ABI} STREQUAL "armeabi-v7a")
    include_directories(${ANDROID_SYSROOT}/usr/include/arm-linux-androideabi)
endif()

Android Studio version 3.0.1 with NDK 16.1.4479499.


Additionally to Alex Cohn answer, in my case a problem was presence of set(CMAKE_C_FLAGS,...) in my CMakeList.txt This declaration overlaps CMAKE_C_FLAGS set in .gradle externalNativeBuild{ cmake { cFlags="..."}}

It seems that -isystem is added by Gradle plugin to CFLAGS not to include dirs list