程序类型已经存在androidx.exifinterface.R

问题描述 投票:0回答:1

我最近在我的android项目中将implementation 'com.google.android.play:core:1.6.4'添加为依赖项,现在Intellij抱怨Program type already present: androidx.exifinterface.R。这是什么意思,我该如何解决?

注意:这是一个问答问题。我已经找到了解决方案,并且想与他人分享。

android gradle
1个回答
0
投票

[最近,我遇到了一个问题,其中android studio会抱怨Program type already present: androidx.exifinterface.R。添加implementation 'com.google.android.play:core:1.6.4'依赖项后发生了这种情况。我以前用androidx.asynclayoutinflater.R偶然发现了这一点。我发现将以下内容添加到模块级gradle文件中可以解决该问题:

configurations.all {
    // This is from a previous, similar issue
    exclude group: "androidx.asynclayoutinflater", module: "asynclayoutinflater"

    // This is the LOC that fixed the issue in this post
    exclude group: "androidx.exifinterface", module: "exifinterface"
}

模式似乎是:

if there's a complaint about androidx.MODULE_X.R already being present
then add 
    exclude group: "androidx.MODULE_X", module: "MODULE_X"
to configurations.all in module level gradle file

这既适用于asynclayoutinflater也适用于现在的exifinterface。我不知道这种模式是否可以扩展,但是到目前为止它已经奏效了。我对基本问题的理解是模块依赖关系图中的两个依赖关系(例如com.google.android.play:core)明确包含有问题的模块(例如exifinterface),因此我们需要排除这些显式依赖关系之一。我的理解可能是错误的。

© www.soinside.com 2019 - 2024. All rights reserved.