Today
-
Yesterday
-
Total
-
  • 💡[문제 상황 - 해결] Task :app:checkDebugDuplicateClasses FAILED
    | 프로그래밍 분야/안드로이드 2021. 6. 5. 02:44

    Receiver 예제를 공부하던 중 빌드 에러가 발생했다.

    매우 간단한 예제로서, 따로 사용해준 외부 라이브러리는 'com.github.pedroSG94:AutoPermissions:1.0.3' 뿐이었다.

    에러 코멘트는 다음과 같다.

    > Task :app:checkDebugDuplicateClasses FAILED
    Execution failed for task ':app:checkDebugDuplicateClasses'.
    > A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
       > Duplicate class android.support.v4.app.INotificationSideChannel found in modules core-1.5.0-runtime (androidx.core:core:1.5.0) and support-compat-27.1.1-runtime (com.android.support:support-compat:27.1.1)
         Duplicate class android.support.v4.app.INotificationSideChannel$Stub found in modules core-1.5.0-runtime (androidx.core:core:1.5.0) and support-compat-27.1.1-runtime (com.android.support:support-compat:27.1.1)
         Duplicate class android.support.v4.app.INotificationSideChannel$Stub$Proxy found in modules core-1.5.0-runtime (androidx.core:core:1.5.0) and support-compat-27.1.1-runtime (com.android.support:support-compat:27.1.1)
         Duplicate class android.support.v4.os.IResultReceiver found in modules core-1.5.0-runtime (androidx.core:core:1.5.0) and support-compat-27.1.1-runtime (com.android.support:support-compat:27.1.1)
         Duplicate class android.support.v4.os.IResultReceiver$Stub found in modules core-1.5.0-runtime (androidx.core:core:1.5.0) and support-compat-27.1.1-runtime (com.android.support:support-compat:27.1.1)
         Duplicate class android.support.v4.os.IResultReceiver$Stub$Proxy found in modules core-1.5.0-runtime (androidx.core:core:1.5.0) and support-compat-27.1.1-runtime (com.android.support:support-compat:27.1.1)
         Duplicate class android.support.v4.os.ResultReceiver found in modules core-1.5.0-runtime (androidx.core:core:1.5.0) and support-compat-27.1.1-runtime (com.android.support:support-compat:27.1.1)
         Duplicate class android.support.v4.os.ResultReceiver$1 found in modules core-1.5.0-runtime (androidx.core:core:1.5.0) and support-compat-27.1.1-runtime (com.android.support:support-compat:27.1.1)
         Duplicate class android.support.v4.os.ResultReceiver$MyResultReceiver found in modules core-1.5.0-runtime (androidx.core:core:1.5.0) and support-compat-27.1.1-runtime (com.android.support:support-compat:27.1.1)
         Duplicate class android.support.v4.os.ResultReceiver$MyRunnable found in modules core-1.5.0-runtime (androidx.core:core:1.5.0) and support-compat-27.1.1-runtime (com.android.support:support-compat:27.1.1)

    * Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

     

    이전에 android - androidx 호환성으로 인한 debugMainManifest 에러와는 또 다른 케이스였다.

     

    💡[문제 상황 - 해결] Task :app:processDebugMainManifest FAILED (Gradle Build Failed)

    [개발 환경] - OS : Windows 10 - IDE : Android Studio - JDK : JAVA SE 16.0.1 - Dependencies : 라이브러리 하나 추가 (com.android.support.design 28.0.0) - 상황 : 간단한 Fragment 예제를 연습하던 중 빌드..

    meoru-tech.tistory.com

     

    이번에는 기본적인 android.os.Bundle과 같이 충돌이 일어나지 않는 라이브러리만 사용한 경우였다. 그래서 androidx로 migration해줄 내용도 없어서 막막했다.

     

    ...라고 생각했는데, 외부 라이브러리를 사용할때에는 gradle.properties에 다음 내용을 추가해줘야 하는 것 같다.

     

    android.useAndroidX=true
    android.enableJetifier=true

     

    useAndroidX는 프로젝트 생성 시 기본적으로 추가되지만, enableJetifier는 Project Structure로 외부 라이브러리를 추가해주지 않으면 추가되지 않는 것 같다.

    (이 예제에서 외부 라이브러리는 build.gradle:app의 dependency를 직접 수정하여 import했었다.)

     

    enableJetifier는 외부 라이브러리의 바이너리를 안드로이드 스튜디오가 자동으로 rewrite하여 androidx와 충돌이 일어나지 않도록 호환해주는 기능이라고 한다.

     

    내용 추가 후 말끔히 해결 :)

sangilyoon.dev@gmail.com