본문 바로가기

Programming/유니티

유니티(Unity) 빌드시 Firebase 오류

ㄴ유니티(Unity) 특수문자 json parsing, jsonUtillity와 litjson
ㄴ유니티(Unity) META-INF/kotlinx_coroutines_core.version
ㄴUndefined symbol : 유니티 Ios 빌드, Pod 설치 및 제거하기
ㄴ유니티(Unity) TextmeshproGui 사용 시 Recttransfrom의 크기가 변경되지 않을 때 (content size filter)
ㄴ유니티 (Unity) - Button의 OnClick Listener 사용법
ㄴ유니티(Unity) 프로젝트 점프게임 만들기 : [7] 플렛폼 생성

빌드 오류

유니티에 서드파티 플러그인을 설치하고 빌드할 때 Firebase 라이브러리를 찾을 수 없다는 빌드 오류를 마주할 때가 있습니다. 특히 다수의 플러그인들이 존재할 때 Firebase가 제일 많이 오류를 발생시키는 것 같습니다. 

----

----

Error Log

Execution failed for task ':launcher:checkReleaseDuplicateClasses'.
> Could not resolve all files for configuration ':launcher:releaseRuntimeClasspath'.
   > Could not find com.google.firebase:firebase-analytics-unity:12.1.0.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/com/google/firebase/firebase-analytics-unity/12.1.0/firebase-analytics-unity-12.1.0.pom
       - https://repo.maven.apache.org/maven2/com/google/firebase/firebase-analytics-unity/12.1.0/firebase-analytics-unity-12.1.0.pom
       - file:/C:/proj/Library/Bee/Android/Prj/IL2CPP/Gradle/unityLibrary/libs/firebase-analytics-unity-12.1.0.jar
       - file:/C:/proj/Library/Bee/Android/Prj/IL2CPP/Gradle/unityLibrary/libs/firebase-analytics-unity.jar
     Required by:
         project :launcher > project :unityLibrary
   > Could not find com.google.firebase:firebase-app-unity:12.1.0.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/com/google/firebase/firebase-app-unity/12.1.0/firebase-app-unity-12.1.0.pom
       - https://repo.maven.apache.org/maven2/com/google/firebase/firebase-app-unity/12.1.0/firebase-app-unity-12.1.0.pom
       - file:/C:/proj/Library/Bee/Android/Prj/IL2CPP/Gradle/unityLibrary/libs/firebase-app-unity-12.1.0.jar
       - file:/C:/proj/Library/Bee/Android/Prj/IL2CPP/Gradle/unityLibrary/libs/firebase-app-unity.jar
     Required by:
         project :launcher > project :unityLibrary
   > Could not find com.google.firebase:firebase-messaging-unity:12.1.0.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/com/google/firebase/firebase-messaging-unity/12.1.0/firebase-messaging-unity-12.1.0.pom
       - https://repo.maven.apache.org/maven2/com/google/firebase/firebase-messaging-unity/12.1.0/firebase-messaging-unity-12.1.0.pom
       - file:/C:/proj/Library/Bee/Android/Prj/IL2CPP/Gradle/unityLibrary/libs/firebase-messaging-unity-12.1.0.jar
       - file:/C:/proj/Library/Bee/Android/Prj/IL2CPP/Gradle/unityLibrary/libs/firebase-messaging-unity.jar
     Required by:
         project :launcher > project :unityLibrary

빌드오류의 원인

저는 파이어베이스 푸시 테스트를 하기 위해서 작업을 하던 중 기존 프로젝트에 여러 가지 플러그인들이 마구 섞여있어서 빈 프로젝트를 만들고 Firebase Sdk를 다운로드하여서 Firebase를 임포트 시키고 EDM(External Dependency Manager) 도 임포트 시켰습니다. (EDM은 Firebase Sdk 안에 포함되어 있습니다.)

 

Unity 프로젝트에 Firebase 추가  |  Firebase for Unity

의견 보내기 Unity 프로젝트에 Firebase 추가 컬렉션을 사용해 정리하기 내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요. Firebase Unity SDK를 활용하여 Unity 게임을 업그레이드해 보세요. Firebase

firebase.google.com

다운로드 링크

그럼 ExternalDependencyManager와 Firebase 폴더가 생긴 것을 확인할 수 있습니다. 이제 유니티 좌상단에서 Assets -> External Dependency Manager -> Android Resolver -> Resolve를 누르게 되면, 무엇인가를 다운로드하는 것처럼 로딩이 걸리다가 GeneratedLocalRepo라는 폴더가 추가된 것을 확인할 수 있습니다. 오류의 원인은 바로 이 폴더가 없기 때문이었습니다.

Custom gradle

Custom mainTemplate.gradle을 사용 중에 Firebase 오류가 발생한다면 settingTemplate.gradle을 확인해봐야 합니다. mainTemplate.gradle 내용 중에 com.google.firebase:firebase-messaging:(버전) x.x.x 이렇게 Firebase 라이브러리를 기재하였다면 settingTemplate.gradle 에 GeneratedLocalRepo의 경로를 세팅해주어야 합니다. 아래는 settingTemplate.gradle의 내용입니다.

pluginManagement {
    repositories {
        **ARTIFACTORYREPOSITORY**
        gradlePluginPortal()
        google()
        mavenCentral()
    }
}

include ':launcher', ':unityLibrary'
**INCLUDES**

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
    repositories {
        **ARTIFACTORYREPOSITORY**
        google()
        mavenCentral()
// Android Resolver Repos Start
        def unityProjectPath = $/file:///**DIR_UNITYPROJECT**/$.replace("\\", "/")
        maven {
            url (unityProjectPath + "/Assets/GeneratedLocalRepo/Firebase/m2repository") // Assets/Firebase/Editor/AnalyticsDependencies.xml:18, Assets/Firebase/Editor/AppDependencies.xml:22, Assets/Firebase/Editor/MessagingDependencies.xml:24
        }
        mavenLocal()
// Android Resolver Repos End
        flatDir {
            dirs "${project(':unityLibrary').projectDir}/libs"
        }
    }
}

이제 원래 프로젝트의 설정과 빈 프로젝트의 설정을 비교해서 작업을 해보시면 될 것 같습니다.