我的项目中只有一个名为 search 的动态功能模块,但是当我尝试构建项目时,我得到了那个错误:
[:search, :search] all package the same library [androidx.recyclerview:recyclerview].
Multiple APKs packaging the same library can cause runtime errors.
Placing each of the above libraries in its own dynamic feature and adding that
feature as a dependency of modules requiring it will resolve this issue.
Libraries that are always used together can be combined into a single feature
module to be imported by their dependents. If a library is required by all
feature modules it can be added to the base module instead.
当然,我做的第一件事是研究有同样问题的人我发现:
两者都引入了相同的解决方案(使用 Android Gradle 插件 4.0)并且我的项目使用 AGP 4.0.1,但问题是我只有一个名为搜索的动态模块。我没有任何其他动态模块,更进一步我没有 RecyclerView 的依赖:androidx.recyclerview:recyclerview
在我的搜索 gradle 文件中,所以这可能是一个传递依赖。
此外,您可以通过以下两种方式之一找到重复的依赖项:
1-导航到:PROJECT_NAME/module_name(在我的情况下:搜索)/build/intermediates/
然后在该目录中搜索“deps.txt”文件,打开文件,您将看到所有模块依赖项直接和传递的
2-运行 ./gradlew :module_name:dependencies 任务
如果您尝试androidx.recyclerview:recyclerview
从“deps.txt”文件中删除该重复的行:它会在每次构建后再次生成。
packagingOptions {}
话虽如此,我需要一些规则来防止和与任何其他格式exclude
之间的冲突search.aar
search.*
有人可以帮忙吗?