Android Studio 报错 executing external native build for cmake xxx CMakeLists.txt

今天带着沉重的心情记录一下这两天的郁闷,因为就在昨天,我把android studio 搞坏了
昨天还是可用的,就因为我升级了什么东西………
然后就一直报错

A problem occurred configuring project ‘:app’ executing external native build for cmake xxx CMakeLists.txt 如下图

Android Studio 报错 executing external native build for cmake xxx CMakeLists.txt_第1张图片

刚开始 ,我没发现 2 和 3 处的错误说明 一直纠结于 1 处的错误。 时间过了一天 毫无效果。

实在无奈 我把android studio 卸载的干干净净。 重装了一遍。

然而, 问题并没有解决,已经到了崩溃的边缘……..

就在这时 我发现了2 和 3的错误说明 ,更可气的是: 3处的 open message view 可以点开唉 ,你妹啊

打开open message view 如下图

Android Studio 报错 executing external native build for cmake xxx CMakeLists.txt_第2张图片

瞬间感觉灵感来了 这么多报错还愁找不到问题所在么

下面是错误的文字版本

External Native Build Issues
Build command failed.
Error while executing process C:\Users\Administrator\AppData\Local\Android\Sdk\cmake\3.6.4111459\bin\cmake.exe with arguments {-HE:\work\android\SerialPortHelper\app -BE:\work\android\SerialPortHelper\app\.externalNativeBuild\cmake\debug\armeabi -GAndroid Gradle - Ninja -DANDROID_ABI=armeabi -DANDROID_NDK=C:\Users\Administrator\AppData\Local\Android\Sdk\ndk-bundle -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=E:\work\android\SerialPortHelper\app\build\intermediates\cmake\debug\obj\armeabi -DCMAKE_BUILD_TYPE=Debug -DCMAKE_MAKE_PROGRAM=C:\Users\Administrator\AppData\Local\Android\Sdk\cmake\3.6.4111459\bin\ninja.exe -DCMAKE_TOOLCHAIN_FILE=C:\Users\Administrator\AppData\Local\Android\Sdk\ndk-bundle\build\cmake\android.toolchain.cmake -DANDROID_PLATFORM=android-19}
CMake Error at C:/Users/Administrator/AppData/Local/Android/sdk/ndk-bundle/build/cmake/android.toolchain.cmake:312 (message):
  Invalid Android ABI: armeabi.  (armeabi is no longer supported.  Use
  armeabi-v7a.)
Call Stack (most recent call first):
  C:/Users/Administrator/AppData/Local/Android/sdk/cmake/3.6.4111459/share/cmake-3.6/Modules/CMakeDetermineSystem.cmake:98 (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!
Build command failed.
Error while executing process C:\Users\Administrator\AppData\Local\Android\Sdk\cmake\3.6.4111459\bin\cmake.exe with arguments {-HE:\work\android\SerialPortHelper\app -BE:\work\android\SerialPortHelper\app\.externalNativeBuild\cmake\release\armeabi -GAndroid Gradle - Ninja -DANDROID_ABI=armeabi -DANDROID_NDK=C:\Users\Administrator\AppData\Local\Android\Sdk\ndk-bundle -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=E:\work\android\SerialPortHelper\app\build\intermediates\cmake\release\obj\armeabi -DCMAKE_BUILD_TYPE=Release -DCMAKE_MAKE_PROGRAM=C:\Users\Administrator\AppData\Local\Android\Sdk\cmake\3.6.4111459\bin\ninja.exe -DCMAKE_TOOLCHAIN_FILE=C:\Users\Administrator\AppData\Local\Android\Sdk\ndk-bundle\build\cmake\android.toolchain.cmake -DANDROID_PLATFORM=android-19}
CMake Error at C:/Users/Administrator/AppData/Local/Android/sdk/ndk-bundle/build/cmake/android.toolchain.cmake:312 (message):
  Invalid Android ABI: armeabi.  (armeabi is no longer supported.  Use
  armeabi-v7a.)
Call Stack (most recent call first):
  C:/Users/Administrator/AppData/Local/Android/sdk/cmake/3.6.4111459/share/cmake-3.6/Modules/CMakeDetermineSystem.cmake:98 (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!

我就一个一个分析 查找错误原因

终于找到了
CMake Error at C:/Users/Administrator/AppData/Local/Android/sdk/ndk-bundle/build/cmake/android.toolchain.cmake:312 (message):
Invalid Android ABI: armeabi. (armeabi is no longer supported. Use
armeabi-v7a.)

意思就是去 文件 android.toolchain.cmake 的 312行查找

Android Studio 报错 executing external native build for cmake xxx CMakeLists.txt_第3张图片

上图的意思大概就是ABI 本来应该和 armeabi-v7a有关系 但是该工程是和armeabi有关系,而不是 armeabi-v7a

那就明白来了啊 ABI 没有配置正确 虽然我不知道ABI 是什么东东

然后就一顿查ABI的配置方法

解决方法如下;在build.grade中添加 图中所示内容

Android Studio 报错 executing external native build for cmake xxx CMakeLists.txt_第4张图片

完美解决

native-lib 是C++动态库名 , 顺便说一下,这个问题只有在调用C++库的时候才会出错,因为ndk就是快速开发C、 C++的动态库,并自动将so和应用一起打包成 APK的。

我看还有人说是:

1 把NDK的版本从10更新到最新的13就OK了
2 在配置中的externalNativeBuild中添加

 splits {  
            abi {  
            enable true  
            reset()  
            include 'x86', 'x86_64', 'armeabi-v7a', 'arm64-v8a' 
            universalApk true  
        }  
    }  

但对于我这个问题都无效

你可能感兴趣的:(Android Studio 报错 executing external native build for cmake xxx CMakeLists.txt)