mac笔记本jni错误 fatal error: 'asm/types.h' file not found

开发环境

mac笔记本 android studio ndk开发
window没毛病。

出现的症状

ILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:externalNativeBuildDebug'.
> Build command failed.
  Error while executing process /Users/aaa/Library/Android/sdk/cmake/3.6.4111459/bin/cmake with arguments {--build /Users/aaa/Documents/redpacket/app/.externalNativeBuild/cmake/debug/armeabi-v7a --target qssq666x}
  [1/2] Building CXX object src/main/cpp/two/CMakeFiles/qssq666x.dir/__/qssq666x.cpp.o
  FAILED: /Users/aaa/Library/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++  --target=armv7-none-linux-androideabi --gcc-toolchain=/Users/aaa/Library/Android/sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64 --sysroot=/Users/aaa/Library/Android/sdk/ndk-bundle/sysroot  -Dqssq666x_EXPORTS -isystem /Users/aaa/Library/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include -isystem /Users/aaa/Library/Android/sdk/ndk-bundle/sources/android/support/include -isystem /Users/aaa/Library/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++abi/include -Wno-error=format-security -Wno-error=pointer-sign -O0 -fno-limit-debug-info  -fPIC -fvisibility=hidden -MD -MT src/main/cpp/two/CMakeFiles/qssq666x.dir/__/qssq666x.cpp.o -MF src/main/cpp/two/CMakeFiles/qssq666x.dir/__/qssq666x.cpp.o.d -o src/main/cpp/two/CMakeFiles/qssq666x.dir/__/qssq666x.cpp.o -c /Users/aaa/Documents/redpacket/app/src/main/cpp/qssq666x.cpp
  In file included from /Users/aaa/Documents/redpacket/app/src/main/cpp/qssq666x.cpp:2:
  In file included from /Users/aaa/Library/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include/string:470:
  In file included from /Users/aaa/Library/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include/string_view:169:
  In file included from /Users/aaa/Library/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include/__string:56:
  In file included from /Users/aaa/Library/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include/algorithm:641:
  In file included from /Users/aaa/Library/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include/cstring:61:
  In file included from /Users/aaa/Library/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include/string.h:61:
  In file included from /Users/aaa/Library/Android/sdk/ndk-bundle/sysroot/usr/include/string.h:36:
  In file included from /Users/aaa/Library/Android/sdk/ndk-bundle/sysroot/usr/include/bits/strcasecmp.h:33:
  In file included from /Users/aaa/Library/Android/sdk/ndk-bundle/sysroot/usr/include/sys/types.h:36:
  /Users/aaa/Library/Android/sdk/ndk-bundle/sysroot/usr/include/linux/types.h:21:10: fatal error: 'asm/types.h' file not found
  #include 
           ^~~~~~~~~~~~~
  1 error generated.
  ninja: build stopped: subcommand failed.


* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

对于开发工具gradle的bug问题,我已经提交问题给谷歌,不知道要何年马月才能解决。
https://issuetracker.google.com/issues/79636791
那么网上的办法也可以解决,但是麻烦。
https://stackoverflow.com/questions/44793617/android-ndk-error-asm-types-h-not-found
https://www.jianshu.com/p/27f98165d73d

我用的解决办法1:
在CMakeLists.txt里面添加

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()

到内容开头

你可能感兴趣的:(mac笔记本jni错误 fatal error: 'asm/types.h' file not found)