Duplicate class com.google.firebase.ktx.Firebase

개요

이번 주부터 프로젝트를 빌드하려고 하니 아래와 같은 오류를 내면서 빌드를 실패하기 시작했습니다.

에러 내용

CommandInvokationFailure: Gradle build failed.
C:\Program Files\Unity\Hub\Editor\2020.3.22f1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK\bin\java.exe -classpath “C:\Program Files\Unity\Hub\Editor\2020.3.22f1\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-6.1.1.jar” org.gradle.launcher.GradleMain “-Dorg.gradle.jvmargs=-Xmx4096m” “assembleRelease”

stderr[
Note: C:\Users\YesTwo\Desktop\work\palddak\palddak\Temp\gradleOut\unityLibrary\src\main\java\com\unity3d\player\UnityPlayerActivity.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:launcher:checkReleaseDuplicateClasses’.

1 exception was raised by workers:
java.lang.RuntimeException: Duplicate class com.google.firebase.ktx.Firebase found in modules jetified-com.google.firebase.firebase-common-20.4.1-runtime.jar (:com.google.firebase.firebase-common-20.4.1:) and jetified-com.google.firebase.firebase-common-ktx-20.3.3-runtime.jar (:com.google.firebase.firebase-common-ktx-20.3.3:)
Duplicate class com.google.firebase.ktx.FirebaseCommonKtxRegistrar found in modules jetified-com.google.firebase.firebase-common-20.4.1-runtime.jar (:com.google.firebase.firebase-common-20.4.1:) and jetified-com.google.firebase.firebase-common-ktx-20.3.3-runtime.jar (:com.google.firebase.firebase-common-ktx-20.3.3:)
Duplicate class com.google.firebase.ktx.FirebaseCommonKtxRegistrar$getComponents$$inlined$coroutineDispatcher$1 found in modules jetified-com.google.firebase.firebase-common-20.4.1-runtime.jar (:com.google.firebase.firebase-common-20.4.1:) and jetified-com.google.firebase.firebase-common-ktx-20.3.3-runtime.jar (:com.google.firebase.firebase-common-ktx-20.3.3:)
Duplicate class com.google.firebase.ktx.FirebaseCommonKtxRegistrar$getComponents$$inlined$coroutineDispatcher$2 found in modules jetified-com.google.firebase.firebase-common-20.4.1-runtime.jar (:com.google.firebase.firebase-common-20.4.1:) and jetified-com.google.firebase.firebase-common-ktx-20.3.3-runtime.jar (:com.google.firebase.firebase-common-ktx-20.3.3:)
Duplicate class com.google.firebase.ktx.FirebaseCommonKtxRegistrar$getComponents$$inlined$coroutineDispatcher$3 found in modules jetified-com.google.firebase.firebase-common-20.4.1-runtime.jar (:com.google.firebase.firebase-common-20.4.1:) and jetified-com.google.firebase.firebase-common-ktx-20.3.3-runtime.jar (:com.google.firebase.firebase-common-ktx-20.3.3:)
Duplicate class com.google.firebase.ktx.FirebaseCommonKtxRegistrar$getComponents$$inlined$coroutineDispatcher$4 found in modules jetified-com.google.firebase.firebase-common-20.4.1-runtime.jar (:com.google.firebase.firebase-common-20.4.1:) and jetified-com.google.firebase.firebase-common-ktx-20.3.3-runtime.jar (:com.google.firebase.firebase-common-ktx-20.3.3:)
Duplicate class com.google.firebase.ktx.FirebaseKt found in modules jetified-com.google.firebase.firebase-common-20.4.1-runtime.jar (:com.google.firebase.firebase-common-20.4.1:) and jetified-com.google.firebase.firebase-common-ktx-20.3.3-runtime.jar (:com.google.firebase.firebase-common-ktx-20.3.3:)
Duplicate class com.google.firebase.ktx.FirebaseKt$coroutineDispatcher$1 found in modules jetified-com.google.firebase.firebase-common-20.4.1-runtime.jar (:com.google.firebase.firebase-common-20.4.1:) and jetified-com.google.firebase.firebase-common-ktx-20.3.3-runtime.jar (:com.google.firebase.firebase-common-ktx-20.3.3:)

찾아보니 10월 1일부터 Firebase를 포함하는 모든 프로젝트를 빌드할 수 없다는 깃허브 이슈가 올라와 있었죠. firebase-common 와 firebase-common-ktx 라이브러리가 버전 업그레이드를 하면서 충돌이 생긴 것으로 보이고 간단하게 ktx 라이브러리를 삭제함으로써 문제를 해결할 수 있었습니다.

해결 방법

  1. Force Resolve 실행
  2. 프로젝트의 ProjectSettings/AndroidResolverDependencies.xml 에서 com.google.firebase.firebase-common-ktx-20.3.3.aar 라인 삭제
  3. Assets/Plugins/Android/com.google.firebase.firebase-common-ktx-20.3.3 파일 삭제
  4. Android Resolver 세팅에서 “Enable Auto-Resolution” 체크 해제

중요한 점은 이 때 다시 Force Resolve를 시키면 안된다는 점입니다. 그러면 다시 ktx 파일이 생기면서 처음부터 다시 시작해야합니다.

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *