본문 바로가기

운동하는 개발자/Android

Duplicate class a.a found in modules jetified-a-release-runtime (:a-release:) and jetified-b-release-runtime (:b-release:)

728x90

우선 이 프로젝트의 구조는 다음과 같다.

lib플젝에서 lib.aar을 생성하고
libEx 플젝에서 lib.aar을 dependencies 하여 libEx.aar를 생성한다.
그리고 app 플젝에서 lib.aar, libEx.aar을 모두 dependencies 한다.

기존 코드에서 gradle, java, Target SDK 버전만 바꿨을 뿐인데 제목과 같은 에러가 발생했다.

Duplicate class a.a found in modules jetified-a-release-runtime (:a-release:) and jetified-b-release-runtime (:b-release:)
Duplicate class a.b found in modules jetified-a-release-runtime (:a-release:) and jetified-b-release-runtime (:b-release:)
Duplicate class b.a found in modules jetified-a-release-runtime (:a-release:) and jetified-b-release-runtime (:b-release:)
Duplicate class c.a found in modules jetified-a-release-runtime (:a-release:) and jetified-b-release-runtime (:b-release:)
Duplicate class c.b found in modules jetified-a-release-runtime (:a-release:) and jetified-b-release-runtime (:b-release:)

찾아보니 내쪽에서 lib.aar과 libEx.aar모두 Proguard를 사용하는데 여기서 클래스명을 난독화하다 보니 두 라이브러리에서 동일한 클래스명이 충돌하여 발생한 에러로 발생한 것이었다.

해결책으로는 libEx.aar의 proguard-rules.pro에 다음과 같이 4줄을 추가해 주면 된다.

-repackageclasses 'kr.co.templib.lib'
-allowaccessmodification
-useuniqueclassmembernames
-keeppackagenames doNotKeepAThing

삽질을 많이 해서 은근 해결하기 힘들었다.


 

728x90