[Unity] Unity 6 빌드 에러: GPGS 플러그인 Gradle 8.x 호환성 문제 해결 (srcaar 이슈)
최근 프로젝트를 Unity 6 (Gradle 8.7 / AGP 8.7.2) 환경으로 올리면서 Android 빌드 시 Google Play Games Plugin (GPGS) 관련 에러가 발생했습니다.
기존 Unity 버전에서는 잘 되던 빌드가 갑자기
srcaar 관련 오류를 뿜으며 실패하는 현상인데, 이는 최신 Gradle의 엄격해진 보안/검증 정책과 GPGS 플러그인의 구버전 패키징 방식이 충돌해서 발생하는 문제입니다.저와 같은 문제를 겪는 분들을 위해 해결 방법을 정리합니다.
1. 발생한 에러 로그
안드로이드 빌드(APK/AAB) 진행 중
mergeReleaseGlobalSynthetics 또는 의존성 해결 단계에서 실패하며 아래와 같은 로그가 출력됩니다.* What went wrong: Execution failed for task ':launcher:mergeReleaseGlobalSynthetics'. > Could not resolve all files for configuration ':launcher:releaseRuntimeClasspath'. > Failed to transform classes.jar (project :unityLibrary) to match attributes {artifactType=android-global-synthetics, ...}. > Could not resolve all files for configuration ':launcher:releaseRuntimeClasspath'. > No variants of com.google.games:gpgs-plugin-support:2.1.0 match the consumer attributes: - Incompatible because this component declares a component, as well as attribute 'artifactType' with value 'srcaar' and the consumer needed a component, as well as attribute 'artifactType' with value 'android-classes-jar'
또는 다음과 같이 파일을 찾을 수 없다는 에러가 나오기도 합니다.
Plaintext
> Could not find com.google.games:gpgs-plugin-support:2.1.0@aar.
2. 원인 분석
이 문제의 핵심은 두 가지입니다.
- Gradle 8.7 (Unity 6)의 변화: 최신 Gradle은 라이브러리의 속성(Attribute)과 확장자를 엄격하게 검사합니다. GPGS 플러그인이 사용하는
.srcaar라는 확장자와 POM 파일의<packaging>srcaar</packaging>설정을 인식하지 못합니다.
- Android Resolver의 동작 방식: 보통
Assets/GeneratedLocalRepo폴더를 수정해서 해결하려 하지만, Unity의 **External Dependency Manager(EDM4U)**는 빌드 때마다 원본 소스 폴더에서 파일을 다시 복사해GeneratedLocalRepo를 덮어씁니다. 즉, 생성된 폴더를 수정해 봤자 다시 원상 복구되어 에러가 재발합니다.
따라서, 리졸버가 참조하는 '원본 소스 파일' 자체를 수정해야 영구적으로 해결됩니다.
3. 해결 방법 (Step-by-Step)
GeneratedLocalRepo가 아닌 Assets 폴더 내의 원본 경로를 수정해야 합니다.단계 1: 원본 라이브러리 폴더로 이동
Unity 프로젝트 내에서 다음 경로를 찾아갑니다.
경로:Assets/GooglePlayGames/com.google.play.games/Editor/m2repository/com/google/games/gpgs-plugin-support/2.1.0/
단계 2: 파일 확장자 변경
해당 폴더 안에 있는 라이브러리 파일의 이름을 변경합니다.
- 변경 전:
gpgs-plugin-support-2.1.0.srcaar
- 변경 후:
gpgs-plugin-support-2.1.0.aar
단계 3: POM 파일 수정 (핵심)
같은 폴더에 있는
gpgs-plugin-support-2.1.0.pom 파일을 메모장이나 코드 에디터로 엽니다.<packaging> 태그의 값을 srcaar에서 aar로 변경합니다.XML
<packaging>srcaar</packaging> <packaging>aar</packaging>
단계 4: 체크섬(Checksum) 파일 삭제
파일의 이름과 내용(POM)을 수정했기 때문에, 기존의 체크섬 파일들과 정보가 맞지 않게 됩니다. 이 파일들이 남아있으면 Gradle이 파일 변조로 판단하여 빌드를 차단합니다.
폴더 내의 다음 확장자 파일들을 모두 삭제합니다.
.md5
.sha1
단계 5: 빌드 실행
이제 Unity 에디터로 돌아와서 바로 빌드(Build)를 실행합니다.
- 별도로
Force Resolve를 누르지 않아도, 빌드 과정에서 Unity가 변경된.aar파일을 감지하고GeneratedLocalRepo에 올바른 파일을 자동으로 복사합니다.
- 이후부터는 정상적으로 빌드가 성공하는 것을 확인할 수 있습니다.
요약
Unity 6 환경에서 GPGS 플러그인 사용 시,
Assets/GooglePlayGames/... 내부의 원본 srcaar 파일을 aar로 변경하고 POM 파일과 체크섬을 정리하면 깔끔하게 해결됩니다.혹시 같은 문제로 고생하고 계신다면 도움이 되길 바랍니다!
Reference: GitHub Issue #3373