android build_error ai_generated true

CMake 错误:/path/to/android-ndk-r26c/build/cmake/android.toolchain.cmake:XX(消息):无效的 Android STL:c++_shared。STL 'c++_shared' 不支持目标架构 'mips'。仅支持 'none' 和 'system'。

CMake Error at /path/to/android-ndk-r26c/build/cmake/android.toolchain.cmake:XX (message): Invalid Android STL: c++_shared. The STL 'c++_shared' is not supported for target architecture 'mips'. Only 'none' and 'system' are supported.

ID: android/ndk-cmake-toolchain-architecture-mismatch

其他格式: JSON · Markdown 中文 · English
88%修复率
84%置信度
1证据数
2024-04-18首次发现

版本兼容性

版本状态引入弃用备注
NDK r26c active
NDK r25b active
CMake 3.22.1 active

根因分析

NDK 的 CMake 工具链配置为针对已弃用或不支持的架构(例如 MIPS)使用该 ABI 不可用的 STL 类型,通常是由于构建脚本中的 `ANDROID_ABI` 或 `APP_ABI` 设置不正确。

English

NDK's CMake toolchain is configured to target a deprecated or unsupported architecture (e.g., MIPS) with an STL type that is not available for that ABI, often due to incorrect `ANDROID_ABI` or `APP_ABI` setting in build scripts.

generic

官方文档

https://developer.android.com/ndk/guides/cmake

解决方案

  1. Update your `build.gradle` (Module: app) to set `abiFilters` to supported architectures only, removing MIPS: `android { defaultConfig { ndk { abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64' } } }`
  2. If using a custom CMake toolchain file, set `set(ANDROID_ABI "arm64-v8a")` before including the NDK toolchain, and ensure `APP_ABI` in `Application.mk` (if using ndk-build) does not include `mips`.

无效尝试

常见但无效的做法:

  1. 90% 失败

    The same error occurs because the architecture (MIPS) does not support any c++ STL variant except 'none' or 'system'. The issue is the ABI, not the STL variant.

  2. 95% 失败

    The error is a configuration issue, not a cache issue. Rebuilding will reproduce the same error if the ABI setting is unchanged.