android build_error ai_generated true

CMake Error at /path/to/android-ndk-r26c/build/cmake/android.toolchain.cmake:XX (message): Unknown ABI: arm64-v8a-hard

ID: android/ndk-cmake-unknown-abi

Also available as: JSON · Markdown · 中文
93%Fix Rate
90%Confidence
1Evidence
2024-03-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
Android NDK r26c active
Android NDK r25b active
CMake 3.22.1 active
Gradle 8.5 active

Root Cause

NDK r26c removed support for the 'arm64-v8a-hard' ABI variant (which had hardware floating-point optimizations) in favor of standard 'arm64-v8a'. Projects still specifying '-hard' suffix in build.gradle or CMakeLists.txt cause this error.

generic

中文

NDK r26c移除了对'arm64-v8a-hard' ABI变体(具有硬件浮点优化)的支持,转而使用标准'arm64-v8a'。仍指定'-hard'后缀的项目在build.gradle或CMakeLists.txt中导致此错误。

Official Documentation

https://developer.android.com/ndk/guides/abis#arm64-v8a

Workarounds

  1. 95% success Change build.gradle ndk.abiFilters to use 'arm64-v8a' instead of 'arm64-v8a-hard'. Example: defaultConfig { ndk { abiFilters 'arm64-v8a', 'x86_64' } }
    Change build.gradle ndk.abiFilters to use 'arm64-v8a' instead of 'arm64-v8a-hard'. Example: defaultConfig { ndk { abiFilters 'arm64-v8a', 'x86_64' } }
  2. 90% success Update CMakeLists.txt to remove any -hard suffix from target_compile_options or set(CMAKE_ANDROID_ARM_MODE ARM) to ensure soft-float is used. Then clean rebuild.
    Update CMakeLists.txt to remove any -hard suffix from target_compile_options or set(CMAKE_ANDROID_ARM_MODE ARM) to ensure soft-float is used. Then clean rebuild.

中文步骤

  1. Change build.gradle ndk.abiFilters to use 'arm64-v8a' instead of 'arm64-v8a-hard'. Example: defaultConfig { ndk { abiFilters 'arm64-v8a', 'x86_64' } }
  2. Update CMakeLists.txt to remove any -hard suffix from target_compile_options or set(CMAKE_ANDROID_ARM_MODE ARM) to ensure soft-float is used. Then clean rebuild.

Dead Ends

Common approaches that don't work:

  1. Set ANDROID_ABI=arm64-v8a-hard in gradle.properties 95% fail

    NDK r26c no longer recognizes this ABI string. Setting it in properties just passes the same invalid value to CMake.

  2. Downgrade NDK to r25b 60% fail

    This works temporarily but prevents using newer NDK features and security patches. Also breaks if other libraries require r26c.