Gradle Duplicated classes found in modules..

윤예은·2022년 9월 16일

개요

내가 불러온 라이브러리끼리 클래스가 겹치는 아주 슬프고 곤란한 상황이 왔다.

해결법

  1. 일단 어떤 라이브러리와 어떤 라이브러리가 같이 있을 때 문제가 발생하는지를 파악한다.
    -> 절반씩 켜보고 꺼보고 하면 더 빠르게 찾을 수 있다.
  2. 그 라이브러리에 아래와 같이 설정을 한다.
implementation ('com.cxpublic:cxense-android:1.0.1') {
    exclude group: "com.android.support", module: "support-v4"
}

라이브러리를 불러올 때 작성하는 것을 보면 그룹:모듈:버전 순으로 되어 있는데, 그룹과 모듈을 한번에 작성하여 어떤 모듈을 딱 집을 수도 있고, 아예 한 그룹의 모듈을 통채로 제거할 수 있다.

다른 해결법

android {
    // Some other stuffs
    configurations {
        all*.exclude module: 'support-v4' // This removes all other versions of `support-v4` if gets duplicated from all the artifacts.
    }
    // Rest of other stuffs
}

아예 모든 라이브러리들에서 해당 모듈을 받아오지 않는다.
모듈 말고 그룹으로 제거할 수도 있다.

참고

https://stackoverflow.com/questions/56695106/duplicated-classes-found-in-modules-classes-jar

profile
안녕하세요!!

0개의 댓글