android andmore项目,Android Studio带C++项目提示More than one file was found with OS independent path问题修正...

本文介绍了在将Android Studio项目升级到新版本gradle 4.0.1后,如何处理因JNI库引用改变导致的编译错误,包括理解错误提示、迁移预编译库到nativeLibs并更新CMakeLists.txt。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

近日,在将一个旧Android Studio项目(带native c/c++)升级了新版本gradle 4.0.1后(Android Studio版本4.0.1),发现重新clean再构建时,提示:

More than one file was found with OS independent path ‘lib/armeabi-v7a/xxx.so’. If you are using jniLibs and CMake IMPORTED targets, see https://developer.

虽然一开始也是一脸茫然,但既然提示信息里都提供了连接了,那就看一下吧,顺带一提,给出的链接我写这篇博文的时候并不是最终信息位置,最终链接在这里:https://developer.android.com/studio/releases/gradle-plugin#cmake-imported-targets ,仔细阅读了一下,发现实际上是从gradle 4.0开始就对jni的预编译依赖引用方式做出了修改:

原来的直接放在“src/main/jniLibs”中的方法已经作废了:

With Android Gradle Plugin 4.0, the above configuration is no longer necessary and will result in a build failure:

* What went wrong:

Execution failed for task ':app:mergeDebugNativeLibs'.

> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade

> More than one file was found with OS independent path 'lib/x86/libprebuilt.so'

External native build now automatically packages those libraries, so explicitly packaging the library with jniLibs results in a duplicate. To avoid the build error, move the prebuilt library to a location outside jniLibs or remove the jniLibs configuration from your build.gradle file.

所以,解决方法就是把jniLibs里的预编译库换个位置,比如把jniLibs改为nativeLibs,当然,CMakeLists.txt中的IMPORTED路径也要做出相应修改,完事再次build即可通过

文字加密小工具v3

请输入要加密的内容

博主友情提示:

如您在评论中需要提及如QQ号、电子邮件地址或其他隐私敏感信息,欢迎使用

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值