android - 打包同一个库的多个 APK 会在 AGP 4.0.1 上仅使用一个动态模块导致运行时错误?
问题描述
我的项目中只有一个名为 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.*
有人可以帮忙吗?
解决方案
就我而言,我从其中一个模块中删除了以下内容
注意:不是来自基本模块
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
推荐阅读
- bash - 没有参数传递给选项时的 getopts 顺序
- javascript - 如何拥有刷新令牌?
- c# - 我应该如何在 firebase 数据库中使用 id
- javascript - 仅在 JS 映射中的值是什么意思以及如何长时间编写它
- bash - 管道标准输出到另一个进程的文件描述符
- python-xarray - Xarray:使用“数据”关键字参数时出错:DataSet.copy() 获得了意外的关键字参数“数据”
- odoo - 表单视图上的 Odoo 面包屑
- r - 在 R 中从 Internet 下载数据时出错
- java - 没有收件人地址 javax.mail
- python - Django pyinstaller 错误 导入错误 myapp