본문 바로가기
error 해결

[Android][Kotlin] 오류 해결 : Duplicate class android.support.v4.app.INotificationSideChannel found in modules core-1.13.1.aar -> core-1.13.1-runtime (androidx.core:core:1.13.1) and support-compat-25.3.1.aar -> support-compat-25.3.1-runtime (com.android.suppo

by 플레이코드 2024. 10. 24.
728x90

이전에 작성한 코드를 수정해 새로운 프로젝트를 수행하던 중 만난 오류입니다. Duplicate class 오류는 class가 중복된 경우에 발생한다고 합니다.

오류 메시지 

Caused by: java.lang.RuntimeException: Duplicate class android.support.v4.app.INotificationSideChannel found in modules core-1.13.1.aar -> core-1.13.1-runtime (androidx.core:core:1.13.1) and support-compat-25.3.1.aar -> support-compat-25.3.1-runtime (com.android.support:support-compat:25.3.1)

 

이 오류의 경우 android.support.v4 class 부분에서 중복이 발생하였습니다. android developer 사이트에서 확인하면, android.support- 로 패키징된 라이브러리는 지원 중단되고 Jetpack으로 대체되었다고 합니다. 연결된 지원 패키지 페이지로 들어가면, 더이상 사용하지 않는 다는 deprecated 표시가 되어 있습니다.

아래의 지원 라이프 패키지 안내에 따르면, androidx 라이브러리 사용을 권장하고 있습니다.

https://developer.android.com/topic/libraries/support-library/packages

 

지원 라이브러리 패키지  |  Android Developers

Android 지원 라이브러리는 애플리케이션에 포함할 수 있는 여러 라이브러리 패키지를 포함하고 있습니다. 이러한 각 라이브러리는 특정 범위의 Android 플랫폼 버전 및 기능 집합을 지원합니다. 이

developer.android.com

해결 방법 : 

gradle.properties 파일에서 android.useAndroidX 항목과 android.enableJetifier 항목을 추가 또는 수정합니다.

gradle.properties 파일의 위치
gradle.properties 위치

해당 항목을 true로 설정하여 추가합니다.

           android.useAndroidX=true
           android.enableJetifier=true

전체 gradle.properties 파일 내용은 다음과 같습니다.

# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. For more details, visit
# https://developer.android.com/r/tools/gradle-multi-project-decoupled-projects
# org.gradle.parallel=true
# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app's APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official
# Enables namespacing of each library's R class so that its R class includes only the
# resources declared in the library itself and none from the library's dependencies,
# thereby reducing the size of the R class for that library
android.nonTransitiveRClass=true
android.enableJetifier=true

 

728x90
LIST