Error : Program type already present: XXXX
Android 开发中经常会遇到 AS 报这个类型的错误,不要慌,这个错误的意思是:你的项目里面存在重复依赖的问题。举个例子:
implementation 'com.github.ifmvo:Matthew_ImageLoader:1.1.3'
implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.43-alpha1'
假如你的项目里面添加了两个依赖,并且这两个依赖里面同时存在另外一种依赖
implementation 'androidx.appcompat:appcompat:1.0.2'
这种情况下编译就会报出 Error : Program type already present: XXXX 这个异常。
那怎么解决这个问题呢?既然是同时存在导致的冲突,那么删除掉一个不就行了么!
implementation 'com.github.ifmvo:Matthew_ImageLoader:1.1.3'
implementation ('com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.43-alpha1'){
exclude group: 'com.android.support', module: 'support-annotations'
}
或
implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.43-alpha1'
implementation ('com.github.ifmvo:Matthew_ImageLoader:1.1.3'){
exclude group: 'com.android.support', module: 'support-annotations'
}
这个异常就解决了!
本文介绍了解决Android开发中因重复依赖导致的Error:Programtypealreadypresent:XXXX错误的方法。通过排除特定依赖项,可以有效避免此类编译时异常。

3699

被折叠的 条评论
为什么被折叠?



