web-dev-qa-db-ja.com

Android ndk error asm types.h not found

Android Studioを2.3.3に更新し、ndkバンドルを更新した後、プロジェクトのビルドに失敗しました。エラーの意味は何ですか?これはIDEのバグであるはずです。問題の修正方法または方法以前のバージョンに戻るにはAndroid Studio/ndkバージョン?

Error:注: 某些输入文件使用或覆盖了已过时的 API。
注: 有关详细信息, 请使用 -Xlint:deprecation 重新编译。
注: /home/noob/code/greatcompany/ExcellentApk/app/src/main/Java/com/greatcompanyx/ExcellentApk/yjzb/CtrlNetTool.Java使用了未经检查或不安全的操作。
注: 有关详细信息, 请使用 -Xlint:unchecked 重新编译。
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:externalNativeBuildRelease'.
> Build command failed.
  Error while executing process /home/noob/Android/Sdk/cmake/3.6.3155560/bin/cmake with arguments {--build /home/noob/code/greatcompany/ExcellentApk/app/.externalNativeBuild/cmake/release/armeabi-v7a --target greatcompany-foot}
  [1/1] Re-running CMake...
  -- Configuring done
  使用Android编译设置
  -- Generating done
  -- Build files have been written to: /home/noob/code/greatcompany/ExcellentApk/app/.externalNativeBuild/cmake/release/armeabi-v7a
  [1/17] Building CXX object src/main/cpp/greatcompany-foot/CMakeFiles/greatcompany-foot.dir/src/Buffer.cpp.o
  [2/17] Building CXX object src/main/cpp/greatcompany-foot/CMakeFiles/greatcompany-foot.dir/src/modules/aec/aec.cpp.o
  [3/17] Building CXX object src/main/cpp/greatcompany-foot/CMakeFiles/greatcompany-foot.dir/src/modules/beamforming/delaysum.cpp.o
  [4/17] Building CXX object src/main/cpp/greatcompany-foot/CMakeFiles/greatcompany-foot.dir/src/modules/kws/sentence/Sentence_kws.cpp.o
  [5/17] Building CXX object src/main/cpp/greatcompany-foot/CMakeFiles/greatcompany-foot.dir/src/modules/kws/sentence/Sentence_posthandler.cpp.o
  [6/17] Building CXX object src/main/cpp/greatcompany-foot/CMakeFiles/greatcompany-foot.dir/src/modules/kws/sentence/Sentence_feature_extractor.cpp.o
  FAILED: /home/noob/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++  --target=armv7-none-linux-androideabi --gcc-toolchain=/home/noob/Android/Sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64 --sysroot=/home/noob/Android/Sdk/ndk-bundle/sysroot  -DANDROID -DNDEBUG -Dgreatcompany_foot_EXPORTS -I../../../../src/main/cpp/greatcompany-foot/src -I../../../../src/main/cpp/greatcompany-foot/src/3rdparty/eigen3 -I../../../../src/main/cpp/greatcompany-foot/src/utils -I../../../../src/main/cpp/greatcompany-foot/src/modules/beamforming -isystem /home/noob/Android/Sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include -isystem /home/noob/Android/Sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/include -isystem /home/noob/Android/Sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/backward -O3 -mfpu=neon -mfloat-abi=softfp -march=armv7-a -Wno-parentheses -Os -DNDEBUG  -fPIC   -std=gnu++11 -MD -MT src/main/cpp/greatcompany-foot/CMakeFiles/greatcompany-foot.dir/src/modules/kws/sentence/Sentence_posthandler.cpp.o -MF src/main/cpp/greatcompany-foot/CMakeFiles/greatcompany-foot.dir/src/modules/kws/sentence/Sentence_posthandler.cpp.o.d -o src/main/cpp/greatcompany-foot/CMakeFiles/greatcompany-foot.dir/src/modules/kws/sentence/Sentence_posthandler.cpp.o -c /home/noob/code/greatcompany/ExcellentApk/app/src/main/cpp/greatcompany-foot/src/modules/kws/sentence/Sentence_posthandler.cpp
  In file included from /home/noob/code/greatcompany/ExcellentApk/app/src/main/cpp/greatcompany-foot/src/modules/kws/sentence/Sentence_posthandler.cpp:5:
  In file included from ../../../../src/main/cpp/greatcompany-foot/src/utils/json/json.h:50:
  In file included from /home/noob/Android/Sdk/ndk-bundle/sysroot/usr/include/stdlib.h:36:
  In file included from /home/noob/Android/Sdk/ndk-bundle/sysroot/usr/include/malloc.h:22:
  In file included from /home/noob/Android/Sdk/ndk-bundle/sysroot/usr/include/stdio.h:42:
  In file included from /home/noob/Android/Sdk/ndk-bundle/sysroot/usr/include/sys/types.h:36:
  /home/noob/Android/Sdk/ndk-bundle/sysroot/usr/include/linux/types.h:21:10: fatal error: 'asm/types.h' file not found
  #include <asm/types.h>
           ^~~~~~~~~~~~~
  1 error generated.
  FAILED: /home/noob/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++  --target=armv7-none-linux-androideabi --gcc-toolchain=/home/noob/Android/Sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64 --sysroot=/home/noob/Android/Sdk/ndk-bundle/sysroot  -DANDROID -DNDEBUG -Dgreatcompany_foot_EXPORTS -I../../../../src/main/cpp/greatcompany-foot/src -I../../../../src/main/cpp/greatcompany-foot/src/3rdparty/eigen3 -I../../../../src/main/cpp/greatcompany-foot/src/utils -I../../../../src/main/cpp/greatcompany-foot/src/modules/beamforming -isystem /home/noob/Android/Sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include -isystem /home/noob/Android/Sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/include -isystem /home/noob/Android/Sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/backward -O3 -mfpu=neon -mfloat-abi=softfp -march=armv7-a -Wno-parentheses -Os -DNDEBUG  -fPIC   -std=gnu++11 -MD -MT src/main/cpp/greatcompany-foot/CMakeFiles/greatcompany-foot.dir/src/modules/kws/sentence/Sentence_feature_extractor.cpp.o -MF src/main/cpp/greatcompany-foot/CMakeFiles/greatcompany-foot.dir/src/modules/kws/sentence/Sentence_feature_extractor.cpp.o.d -o src/main/cpp/greatcompany-foot/CMakeFiles/greatcompany-foot.dir/src/modules/kws/sentence/Sentence_feature_extractor.cpp.o -c /home/noob/code/greatcompany/ExcellentApk/app/src/main/cpp/greatcompany-foot/src/modules/kws/sentence/Sentence_feature_extractor.cpp
  In file included from /home/noob/code/greatcompany/ExcellentApk/app/src/main/cpp/greatcompany-foot/src/modules/kws/sentence/Sentence_feature_extractor.cpp:5:
  In file included from /home/noob/code/greatcompany/ExcellentApk/app/src/main/cpp/greatcompany-foot/src/modules/kws/sentence/Sentence_feature_extractor.h:18:
  In file included from /home/noob/Android/Sdk/ndk-bundle/sysroot/usr/include/stdlib.h:36:
  In file included from /home/noob/Android/Sdk/ndk-bundle/sysroot/usr/include/malloc.h:22:
  In file included from /home/noob/Android/Sdk/ndk-bundle/sysroot/usr/include/stdio.h:42:
  In file included from /home/noob/Android/Sdk/ndk-bundle/sysroot/usr/include/sys/types.h:36:
  /home/noob/Android/Sdk/ndk-bundle/sysroot/usr/include/linux/types.h:21:10: fatal error: 'asm/types.h' file not found
  #include <asm/types.h>
           ^~~~~~~~~~~~~
  1 error generated.
  FAILED: /home/noob/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++  --target=armv7-none-linux-androideabi --gcc-toolchain=/home/noob/Android/Sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64 --sysroot=/home/noob/Android/Sdk/ndk-bundle/sysroot  -DANDROID -DNDEBUG -Dgreatcompany_foot_EXPORTS -I../../../../src/main/cpp/greatcompany-foot/src -I../../../../src/main/cpp/greatcompany-foot/src/3rdparty/eigen3 -I../../../../src/main/cpp/greatcompany-foot/src/utils -I../../../../src/main/cpp/greatcompany-foot/src/modules/beamforming -isystem /home/noob/Android/Sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include -isystem /home/noob/Android/Sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/include -isystem /home/noob/Android/Sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/backward -O3 -mfpu=neon -mfloat-abi=softfp -march=armv7-a -Wno-parentheses -Os -DNDEBUG  -fPIC   -std=gnu++11 -MD -MT src/main/cpp/greatcompany-foot/CMakeFiles/greatcompany-foot.dir/src/modules/aec/aec.cpp.o -MF src/main/cpp/greatcompany-foot/CMakeFiles/greatcompany-foot.dir/src/modules/aec/aec.cpp.o.d -o src/main/cpp/greatcompany-foot/CMakeFiles/greatcompany-foot.dir/src/modules/aec/aec.cpp.o -c /home/noob/code/greatcompany/ExcellentApk/app/src/main/cpp/greatcompany-foot/src/modules/aec/aec.cpp
  In file included from /home/noob/code/greatcompany/ExcellentApk/app/src/main/cpp/greatcompany-foot/src/modules/aec/aec.cpp:5:
  In file included from /home/noob/Android/Sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/iostream:39:
  In file included from /home/noob/Android/Sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/ostream:38:
  In file included from /home/noob/Android/Sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/ios:38:
  In file included from /home/noob/Android/Sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/iosfwd:40:
  In file included from /home/noob/Android/Sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/postypes.h:40:
  In file included from /home/noob/Android/Sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/cwchar:44:
  In file included from /home/noob/Android/Sdk/ndk-bundle/sysroot/usr/include/wchar.h:32:
  In file included from /home/noob/Android/Sdk/ndk-bundle/sysroot/usr/include/stdio.h:42:
  In file included from /home/noob/Android/Sdk/ndk-bundle/sysroot/usr/include/sys/types.h:36:
  /home/noob/Android/Sdk/ndk-bundle/sysroot/usr/include/linux/types.h:21:10: fatal error: 'asm/types.h' file not found
  #include <asm/types.h>
           ^~~~~~~~~~~~~
  1 error generated.
  FAILED: /home/noob/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++  --target=armv7-none-linux-androideabi --gcc-toolchain=/home/noob/Android/Sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64 --sysroot=/home/noob/Android/Sdk/ndk-bundle/sysroot  -DANDROID -DNDEBUG -Dgreatcompany_foot_EXPORTS -I../../../../src/main/cpp/greatcompany-foot/src -I../../../../src/main/cpp/greatcompany-foot/src/3rdparty/eigen3 -I../../../../src/main/cpp/greatcompany-foot/src/utils -I../../../../src/main/cpp/greatcompany-foot/src/modules/beamforming -isystem /home/noob/Android/Sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include -isystem /home/noob/Android/Sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/include -isystem /home/noob/Android/Sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/backward -O3 -mfpu=neon -mfloat-abi=softfp -march=armv7-a -Wno-parentheses -Os -DNDEBUG  -fPIC   -std=gnu++11 -MD -MT src/main/cpp/greatcompany-foot/CMakeFiles/greatcompany-foot.dir/src/modules/kws/sentence/Sentence_kws.cpp.o -MF src/main/cpp/greatcompany-foot/CMakeFiles/greatcompany-foot.dir/src/modules/kws/sentence/Sentence_kws.cpp.o.d -o src/main/cpp/greatcompany-foot/CMakeFiles/greatcompany-foot.dir/src/modules/kws/sentence/Sentence_kws.cpp.o -c /home/noob/code/greatcompany/ExcellentApk/app/src/main/cpp/greatcompany-foot/src/modules/kws/sentence/Sentence_kws.cpp
  In file included from /home/noob/code/greatcompany/ExcellentApk/app/src/main/cpp/greatcompany-foot/src/modules/kws/sentence/Sentence_kws.cpp:6:
  In file included from ../../../../src/main/cpp/greatcompany-foot/src/utils/json/json.h:50:
  In file included from /home/noob/Android/Sdk/ndk-bundle/sysroot/usr/include/stdlib.h:36:
  In file included from /home/noob/Android/Sdk/ndk-bundle/sysroot/usr/include/malloc.h:22:
  In file included from /home/noob/Android/Sdk/ndk-bundle/sysroot/usr/include/stdio.h:42:
  In file included from /home/noob/Android/Sdk/ndk-bundle/sysroot/usr/include/sys/types.h:36:
  /home/noob/Android/Sdk/ndk-bundle/sysroot/usr/include/linux/types.h:21:10: fatal error: 'asm/types.h' file not found
  #include <asm/types.h>
           ^~~~~~~~~~~~~
  1 error generated.
  FAILED: /home/noob/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++  --target=armv7-none-linux-androideabi --gcc-toolchain=/home/noob/Android/Sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64 --sysroot=/home/noob/Android/Sdk/ndk-bundle/sysroot  -DANDROID -DNDEBUG -Dgreatcompany_foot_EXPORTS -I../../../../src/main/cpp/greatcompany-foot/src -I../../../../src/main/cpp/greatcompany-foot/src/3rdparty/eigen3 -I../../../../src/main/cpp/greatcompany-foot/src/utils -I../../../../src/main/cpp/greatcompany-foot/src/modules/beamforming -isystem /home/noob/Android/Sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include -isystem /home/noob/Android/Sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/include -isystem /home/noob/Android/Sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/backward -O3 -mfpu=neon -mfloat-abi=softfp -march=armv7-a -Wno-parentheses -Os -DNDEBUG  -fPIC   -std=gnu++11 -MD -MT src/main/cpp/greatcompany-foot/CMakeFiles/greatcompany-foot.dir/src/Buffer.cpp.o -MF src/main/cpp/greatcompany-foot/CMakeFiles/greatcompany-foot.dir/src/Buffer.cpp.o.d -o src/main/cpp/greatcompany-foot/CMakeFiles/greatcompany-foot.dir/src/Buffer.cpp.o -c /home/noob/code/greatcompany/ExcellentApk/app/src/main/cpp/greatcompany-foot/src/Buffer.cpp
  In file included from /home/noob/code/greatcompany/ExcellentApk/app/src/main/cpp/greatcompany-foot/src/Buffer.cpp:5:
  In file included from ../../../../src/main/cpp/greatcompany-foot/src/Buffer.h:11:
  In file included from ../../../../src/main/cpp/greatcompany-foot/src/3rdparty/eigen3/Eigen/Core:80:
  In file included from /home/noob/Android/Sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/complex:45:
  In file included from /home/noob/Android/Sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/sstream:38:
  In file included from /home/noob/Android/Sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/istream:38:
  In file included from /home/noob/Android/Sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/ios:38:
  In file included from /home/noob/Android/Sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/iosfwd:40:
  In file included from /home/noob/Android/Sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/postypes.h:40:
  In file included from /home/noob/Android/Sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/cwchar:44:
  In file included from /home/noob/Android/Sdk/ndk-bundle/sysroot/usr/include/wchar.h:32:
  In file included from /home/noob/Android/Sdk/ndk-bundle/sysroot/usr/include/stdio.h:42:
  In file included from /home/noob/Android/Sdk/ndk-bundle/sysroot/usr/include/sys/types.h:36:
  /home/noob/Android/Sdk/ndk-bundle/sysroot/usr/include/linux/types.h:21:10: fatal error: 'asm/types.h' file not found
  #include <asm/types.h>
           ^~~~~~~~~~~~~
  1 error generated.
  FAILED: /home/noob/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++  --target=armv7-none-linux-androideabi --gcc-toolchain=/home/noob/Android/Sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64 --sysroot=/home/noob/Android/Sdk/ndk-bundle/sysroot  -DANDROID -DNDEBUG -Dgreatcompany_foot_EXPORTS -I../../../../src/main/cpp/greatcompany-foot/src -I../../../../src/main/cpp/greatcompany-foot/src/3rdparty/eigen3 -I../../../../src/main/cpp/greatcompany-foot/src/utils -I../../../../src/main/cpp/greatcompany-foot/src/modules/beamforming -isystem /home/noob/Android/Sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include -isystem /home/noob/Android/Sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/include -isystem /home/noob/Android/Sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/backward -O3 -mfpu=neon -mfloat-abi=softfp -march=armv7-a -Wno-parentheses -Os -DNDEBUG  -fPIC   -std=gnu++11 -MD -MT src/main/cpp/greatcompany-foot/CMakeFiles/greatcompany-foot.dir/src/modules/beamforming/delaysum.cpp.o -MF src/main/cpp/greatcompany-foot/CMakeFiles/greatcompany-foot.dir/src/modules/beamforming/delaysum.cpp.o.d -o src/main/cpp/greatcompany-foot/CMakeFiles/greatcompany-foot.dir/src/modules/beamforming/delaysum.cpp.o -c /home/noob/code/greatcompany/ExcellentApk/app/src/main/cpp/greatcompany-foot/src/modules/beamforming/delaysum.cpp
  In file included from /home/noob/code/greatcompany/ExcellentApk/app/src/main/cpp/greatcompany-foot/src/modules/beamforming/delaysum.cpp:4:
  In file included from ../../../../src/main/cpp/greatcompany-foot/src/modules/beamforming/delaysum.h:14:
  In file included from ../../../../src/main/cpp/greatcompany-foot/src/3rdparty/eigen3/Eigen/Dense:1:
  In file included from ../../../../src/main/cpp/greatcompany-foot/src/3rdparty/eigen3/Eigen/Core:80:
  In file included from /home/noob/Android/Sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/complex:45:
  In file included from /home/noob/Android/Sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/sstream:38:
  In file included from /home/noob/Android/Sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/istream:38:
  In file included from /home/noob/Android/Sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/ios:38:
  In file included from /home/noob/Android/Sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/iosfwd:40:
  In file included from /home/noob/Android/Sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/postypes.h:40:
  In file included from /home/noob/Android/Sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/cwchar:44:
  In file included from /home/noob/Android/Sdk/ndk-bundle/sysroot/usr/include/wchar.h:32:
  In file included from /home/noob/Android/Sdk/ndk-bundle/sysroot/usr/include/stdio.h:42:
  In file included from /home/noob/Android/Sdk/ndk-bundle/sysroot/usr/include/sys/types.h:36:
  /home/noob/Android/Sdk/ndk-bundle/sysroot/usr/include/linux/types.h:21:10: fatal error: 'asm/types.h' file not found
  #include <asm/types.h>
           ^~~~~~~~~~~~~
  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.
7
Cauchy Schwarz

Android studio 3.0およびndk 15では、このエラーも発生しました。しかし、これを解決しましたが、中国語で分析しました。

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

方法 :

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

方法2

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

方法3

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

10
lemac

Lemacの回答の方法1は、わずかな変更を加えるだけで機能します。

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バージョン3.0.1、NDK 16.1.4479499。

8

Alex Cohnの回答に加えて、私の場合、問題はCMakeList.txtにset(CMAKE_C_FLAGS,...)が存在することでした。この宣言は、.gradleに設定されたCMAKE_C_FLAGSと重複していますexternalNativeBuild{ cmake { cFlags="..."}}

-isystemがdirsリストを含めないようにCFLAGSにGradleプラグインによって追加されているようです

4
Rafal.K

コンパイルパラメータがありません

_-isystem /home/noob/Android/Sdk/ndk-bundle/sysroot/usr/include/arm-linux-androideabi
_

NDKをr15にアップグレードしましたが、Android St​​udioとgradleプラグインはアップグレードしていません。私にとっては、Android St​​udio 3.0(プレビュー)と_'com.Android.tools.build:gradle:2.3.1'_(最新ではない)を使用すると、正しいコンパイルコマンドが生成されます。

Android St​​udioのプレビューバージョンに切り替えたくない場合は、_…/include/arm-linux-androideabi_へのパスを手動で追加できます。

1
Alex Cohn

私は非常によく似たケースに遭遇しました。 CMAKE_C_FLAGSおよびCMAKE_CXX_FLAGS in CMakeLists.txt:

set(CMAKE_C_FLAGS "${MY_CUSTOM_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${MY_CUSTOM_CXX_FLAGS}")

ただし、cmakeを呼び出すときにAndroid.toolchain.cmakeがツールチェーンファイルとして使用されるため、cmakeは最初にAndroid.toolchain.cmakeのコンテンツ(CMAKE_C_FLAGSおよびCMAKE_CXX_FLAGSに値を設定します)を解釈してから、CMakeLists.txtに設定をロードします。つまり、私は最終的にこれに変更しました:

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MY_CUSTOM_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MY_CUSTOM_CXX_FLAGS}")
0
HaxtraZ