Installation failed with message INSTALL_FAILED_NO_MATCHING_ABIS: Failed to extract native libraries

本文详细解析了在Android模拟器上遇到的INSTALL_FAILED_NO_MATCHING_ABIS错误,该错误通常由于应用依赖于特定CPU架构的原生库而引发。文章提供了修改build.gradle文件的具体方法,通过增加abi配置来确保应用能在不同架构的设备上正确运行。

在模拟器上运行项目出现:

Installation failed with message INSTALL_FAILED_NO_MATCHING_ABIS: Failed to extract native libraries, res=-113.
It is possible that this issue is resolved by uninstalling an existing version of the apk if it is present, and then 
re-installing.

WARNING: Uninstalling will remove the application data!

Do you want to uninstall the existing application?

翻译:

安装失败并显示消息INSTALL_FAILED_NO_MATCHING_ABIS:无法提取本机库,res = -113。
可以通过卸载apk的现有版本(如果存在)然后重新安装来解决此问题。

警告:卸载将删除应用程序数据!

您要卸载现有的应用程序吗?

模拟器上经常出现,原因是我应用使用了原生库(NDK,Native Lib),这些库的编译目标通常是arm架构的cpu,在x86上运行就会报这样的错误。

解决办法:

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.example.a86131.ocd"
        minSdkVersion 21
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {

        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

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

    ···
}

在Module的build.gradle里面增加split{}这一段代码即可。

### 问题分析 错误信息 `INSTALL_FAILED_NO_MATCHING_ABIS: Failed to extract native libraries, res=-113` 表明 Android 系统在安装应用时无法找到与设备架构兼容的原生库(native libraries)。这通常发生在应用仅包含 32 位或 64 位支持,而目标设备不匹配的情况下。Android 支持多种 ABI(Application Binary Interface),包括 `armeabi-v7a`、`arm64-v8a`、`x86` 和 `x86_64`。 ### 解决方案 #### 1. 配置构建设置以支持多个 ABI 确保编译器生成的应用程序支持多个 ABI,特别是 `arm64-v8a`,这是现代 64 位 Android 设备的标准架构。 - **Qt Creator 用户**:进入项目设置,选择 *Build & Run* -> *Build* 步骤,展开详情并勾选 `arm64-v8a` 选项,重新编译并安装应用程序[^1]。 - **Android Studio 用户**:在 `build.gradle` 文件中配置 ABI 切分支持: ```gradle android { ... splits { abi { enable true reset() include 'x86', 'armeabi-v7a', 'x86_64', 'arm64-v8a' universalApk true } } } ``` 上述配置将生成一个包含所有指定架构的通用 APK,从而提升设备兼容性[^4]。 #### 2. 检查依赖库的 ABI 支持 如果使用了第三方库,确认这些库是否提供对所有主要 ABI 的支持。缺失某些 ABI 的 `.so` 文件会导致安装失败。可以通过解压 APK 并检查 `lib/` 目录下的子目录(如 `armeabi-v7a` 或 `arm64-v8a`)来验证是否存在对应的 `.so` 文件[^5]。 #### 3. 卸载旧版本应用 有时旧版本应用可能已安装,并且其 ABI 支持与当前构建不一致。尝试卸载旧版本再重新安装新 APK。系统提示如下时,可以选择继续卸载: > "Installation failed with message INSTALL_FAILED_NO_MATCHING_ABIS: Failed to extract native libraries, res=-113. It is possible that this issue is resolved by uninstalling an existing version of the apk if it is present, and then re-installing."[^3] #### 4. 使用命令行工具手动安装 通过 ADB 手动安装 APK 以获取更详细的错误输出,有助于排查具体原因: ```bash adb install -r app-release.apk ``` 若安装失败,可通过以下命令清除应用数据后再次尝试: ```bash adb shell pm clear <package_name> adb uninstall <package_name> adb install -r app-release.apk ``` #### 5. 查阅官方文档与社区资源 建议参考以下资源进一步了解 ABI 分割和兼容性处理: - [Android ABI 文档](http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits) - [Stack Overflow 关于 INSTALL_FAILED_NO_MATCHING_ABIS 的讨论](https://stackoverflow.com/questions/24572052/install-failed-no-matching-abis-when-install-apk) --- ###
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

是宇哥啊

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值