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

- **ID:** `android/ndk-cmake-toolchain-architecture-mismatch`
- **领域:** android
- **类别:** build_error
- **验证级别:** ai_generated
- **修复率:** 88%

## 根因

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

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| NDK r26c | active | — | — |
| NDK r25b | active | — | — |
| CMake 3.22.1 | active | — | — |

## 解决方案

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`.
   ```

## 无效尝试

- **** — 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. (90% 失败率)
- **** — The error is a configuration issue, not a cache issue. Rebuilding will reproduce the same error if the ABI setting is unchanged. (95% 失败率)
