AndroidStudio4.0版本More than one file was found with OS independent
程序员文章站
2022-05-30 14:13:50
...
最近把Android Studio从3.4.x 升级到4.x.x,Gradle Plugin从3.4.x 升级到4.0.1,Gradle从4.1升级到6.1.1,导致原来使用Cmake构建的项目编译失败了。下面我们看看原因是啥:
自动打包 CMake 使用的预构建依赖项
早期版本的 Android Gradle 插件要求您使用 jniLibs 明确打包您的 CMake 外部原生 build 使用的所有预构建库。您的库可能位于模块的 src/main/jniLibs 目录中,也可能位于在 build.gradle 文件中配置的某个其他目录中:
sourceSets {
main {
// The libs directory contains prebuilt libraries that are used by the
// app's library defined in CMakeLists.txt via an IMPORTED target.
jniLibs.srcDirs = ['libs']
}
}
有了 Android Gradle 插件 4.0,上述配置不再是必需的,并且会导致构建失败:
* 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'
外部原生 build 现在会自动打包这些库,因此使用 jniLibs 明确打包库会导致重复。为了避免构建错误,请将预构建库移至 jniLibs 之外的位置,或从 build.gradle 文件中移除 jniLibs 配置。
怎么解决呢?
1、如果您的库位于模块的 src/main/jniLibs
目录中,那么直接把 jniLibs
名称改下喽,比如改成:jniLibList
2、如果您的库位于在 build.gradle 文件中配置的某个其他目录中,直接在build.gradle 文件中删除配置即可;
推荐阅读
-
More than one file was found with OS independent path 'lib/armeabi-v7a/libgnustl_shared.so'
-
More than one file was found with OS independent path 'assets/ap1.data'
-
AndroidStudio4.0版本More than one file was found with OS independent
-
Android:More than one file was found with OS independent path 'res/values/values.xml
-
Android studio 配置Javacv出现“More than one file was found with OS independent path”的解决办法
-
Android - jni - error:More than one file was found with OS independent path ‘lib/*so‘
-
Android问题集锦(十) - More than one file was found with OS independent path 'META-INF/DEPENDENCIES'
-
More than one file was found with OS independent path 'lib/armeabi-v7a/libgnustl_shared.so'