Android 如果AGP 4.0.1上只有一个动态模块,多个APK打包同一个库可能会导致运行时错误?

Android 如果AGP 4.0.1上只有一个动态模块,多个APK打包同一个库可能会导致运行时错误?,android,modularity,android-app-bundle,dynamic-feature-module,Android,Modularity,Android App Bundle,Dynamic Feature Module,我的项目中只有一个名为“搜索”的动态功能模块,但当我尝试构建项目时,会出现以下错误: [: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 i

我的项目中只有一个名为“搜索”的动态功能模块,但当我尝试构建项目时,会出现以下错误:

    [: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.
当然,我做的第一件事就是研究那些有同样问题的人,我发现:

1- 2-

两者都引入了相同的解决方案(使用Android Gradle Plugin 4.0),我的项目使用AGP4.0.1,但问题是我只有一个称为搜索的动态模块。我没有任何其他动态模块,甚至在我的search gradle文件中没有RecyclerView:
androidx.RecyclerView:RecyclerView
的依赖关系,因此这可能是一个可传递的依赖关系

此外,您可以通过以下两种方式之一找到重复的依赖关系:

1-导航到:项目名称/模块名称(在我的示例中为搜索)/构建/中间产品/

然后在该目录中搜索“deps.txt”文件,打开该文件,您将看到所有模块依赖项直接和可传递的依赖项

2-运行./gradlew:module_name:dependencies任务

如果您试图从“deps.txt”文件中删除重复的行:
androidx.recyclerview:recyclerview
,则每次生成后都会再次生成该行

也就是说,我需要在我的
packagingOptions{}
中加入一些规则,比如
exclude
,以防止
search.aar
和任何其他
search.
格式之间的冲突


有人能帮忙吗?

就我而言,我从其中一个模块中删除了下面的内容

注意:不是来自基本模块


在我的例子中,Gradle给了我一个libraray的错误``implementation'androidx.legacy:legacy-support-v4:1.0.0``我在一个功能模块sync project中删除了这个库,这解决了我的错误。从功能模块中删除“`androidx.recyclerview:recyclerview````我希望您的错误能够得到解决。
implementation 'androidx.legacy:legacy-support-v4:1.0.0'