-
(30초 읽기) Duplicate Class Error: AndroidX vs Support Library 충돌 해결법! 🚫💥Android 개발/오류 해결 2025. 1. 9. 18:40
Duplicate class android.support.v4.app.INotificationSideChannel found in modules core-1.15.0.aar -> core-1.15.0-runtime (androidx.core:core:1.15.0) and support-compat-25.1.1.aar -> support-compat-25.1.1-runtime (com.android.support:support-compat:25.1.1) Duplicate class android.support.v4.app.INotificationSideChannel$Stub found in modules core-1.15.0.aar -> core-1.15.0-runtime (androidx.core:core:1.15.0) and support-compat-25.1.1.aar -> support-compat-25.1.1-runtime (com.android.support:support-compat:25.1.1) Duplicate class android.support.v4.app.INotificationSideChannel$Stub$Proxy found in modules core-1.15.0.aar -> core-1.15.0-runtime (androidx.core:core:1.15.0) and support-compat-25.1.1.aar -> support-compat-25.1.1-runtime (com.android.support:support-compat:25.1.1) Duplicate class android.support.v4.os.IResultReceiver found in modules core-1.15.0.aar -> core-1.15.0-runtime (androidx.core:core:1.15.0) and support-compat-25.1.1.aar -> support-compat-25.1.1-runtime (com.android.support:support-compat:25.1.1) Duplicate class android.support.v4.os.IResultReceiver$Stub found in modules core-1.15.0.aar -> core-1.15.0-runtime (androidx.core:core:1.15.0) and support-compat-25.1.1.aar -> support-compat-25.1.1-runtime (com.android.support:support-compat:25.1.1) Duplicate class android.support.v4.os.IResultReceiver$Stub$Proxy found in modules core-1.15.0.aar -> core-1.15.0-runtime (androidx.core:core:1.15.0) and support-compat-25.1.1.aar -> support-compat-25.1.1-runtime (com.android.support:support-compat:25.1.1) Duplicate class android.support.v4.os.ResultReceiver found in modules core-1.15.0.aar -> core-1.15.0-runtime (androidx.core:core:1.15.0) and support-compat-25.1.1.aar -> support-compat-25.1.1-runtime (com.android.support:support-compat:25.1.1) Duplicate class android.support.v4.os.ResultReceiver$1 found in modules core-1.15.0.aar -> core-1.15.0-runtime (androidx.core:core:1.15.0) and support-compat-25.1.1.aar -> support-compat-25.1.1-runtime (com.android.support:support-compat:25.1.1) Duplicate class android.support.v4.os.ResultReceiver$MyResultReceiver found in modules core-1.15.0.aar -> core-1.15.0-runtime (androidx.core:core:1.15.0) and support-compat-25.1.1.aar -> support-compat-25.1.1-runtime (com.android.support:support-compat:25.1.1) Duplicate class android.support.v4.os.ResultReceiver$MyRunnable found in modules core-1.15.0.aar -> core-1.15.0-runtime (androidx.core:core:1.15.0) and support-compat-25.1.1.aar -> support-compat-25.1.1-runtime (com.android.support:support-compat:25.1.1) Go to the documentation to learn how to Fix dependency resolution errors.
에러 원인
Duplicate class android.support.v4.* 오류는 AndroidX와 Support Library가 동시에 사용될 때 발생해.
- androidx.core:core:1.15.0 ← AndroidX 라이브러리
- com.android.support:support-compat:25.1.1 ← Support Library
이 둘은 서로 호환되지 않고, 동일한 클래스(android.support.v4.*)를 포함하고 있어서 충돌해! 😓
🔥 주요 원인
- AndroidX와 Support Library 동시 사용
- AndroidX는 androidx.* 패키지로, Support Library는 android.support.* 패키지로 구분돼.
- 두 라이브러리는 서로 호환되지 않으니 하나만 사용해야 해.
- 의존성 중첩 문제
- 프로젝트에서 사용하는 라이브러리 중 일부는 AndroidX, 나머지는 Support Library를 사용할 수 있어.
- 특히, 오래된 서드파티 라이브러리가 Support Library를 의존하고 있을 가능성이 높아.
💡 해결 방법
1. Jetifier 활성화
Support Library를 AndroidX로 자동 변환해 주는 Jetifier를 사용하면 충돌 문제를 해결할 수 있어! 🔧
방법:
gradle.properties 파일에 아래 코드를 추가해:android.useAndroidX=true android.enableJetifier=true
이렇게 하면 Support Library를 자동으로 AndroidX로 변환해주기 때문에 중복 클래스 오류가 사라져! 🎉
🚀 추가 팁
- Support Library는 AndroidX로 완전히 대체되었으니,
- 가능하면 모든 라이브러리를 최신 버전으로 업데이트하고
- Support Library → AndroidX로 완전 이전하는 걸 추천해!
- build.gradle에서 com.android.support:로 시작하는 의존성을 모두 AndroidX로 교체해.
이제 AndroidX와 Support Library 충돌 없이 깔끔한 빌드가 가능할 거야! 🚀
Jetifier 덕분에 레거시 코드도 걱정 없이 AndroidX로 전환해보자! 😎'Android 개발 > 오류 해결' 카테고리의 다른 글