[Flutter] Android Build Failed, Unable to load Maven meta-data, Received status code 502 from server: Bad Gateway

Taehyun Nam·2021년 12월 15일
0
post-thumbnail

어느날 Android Build 할때 아래와 같은 에러가 발생하였음.
StackOverflow에 다양한 해결방법이 있는데, 모두 해결되지 않았음..😢

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> Could not resolve all dependencies for configuration ':app:debugCompileClasspath'.
   > Problems reading data from Binary store in /private/var/folders/j2/ggndzrfn1_jgt0txr40qg1cm0000gn/T/gradle2895455314803480677.bin offset 386213 exists? true

* 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.

* Get more help at https://help.gradle.org

BUILD FAILED in 24s
Exception: Gradle task assembleDebug failed with exit code 1

빌드 옵션 추가(선택)

아래 명령어로 warning에 대한 정보를 출력해봤는데, warning이라서 실행이 안되는 직접적인 원인은 아니라서 수정하지 않아도 동작한다고 해서 패스🚣🏻

./gradlew build --warning-mode all
teddy@namtaehyeon-ui-MacBookPro android % ./gradlew build --warning-mode all
Starting a Gradle Daemon, 1 incompatible Daemon could not be reused, use --status for details

> Configure project :app
The BuildListener.buildStarted(Gradle) method has been deprecated. This is scheduled to be removed in Gradle 7.0. Consult the upgrading guide for further information: https://docs.gradle.org/6.5/userguide/upgrading_version_5.html#apis_buildlistener_buildstarted_and_gradle_buildstarted_have_been_deprecated
        at build_cq1n0oyl98bqbhqx9r4qjnrdx.run(/Users/teddy/DEV/martjangbogo-mobile/android/app/build.gradle:31)
        (Run with --stacktrace to get the full stack trace of this deprecation warning.)
Internal API constructor DefaultDomainObjectSet(Class<T>) has been deprecated. This is scheduled to be removed in Gradle 7.0. Please use ObjectFactory.domainObjectSet(Class<T>) instead. See https://docs.gradle.org/6.5/userguide/custom_gradle_types.html#domainobjectset for more details.
        at build_cq1n0oyl98bqbhqx9r4qjnrdx.run(/Users/teddy/DEV/martjangbogo-mobile/android/app/build.gradle:31)
        (Run with --stacktrace to get the full stack trace of this deprecation warning.)
WARNING: DSL element 'useProguard' is obsolete and will be removed soon. Use 'android.enableR8' in gradle.properties to switch between R8 and Proguard..
The AbstractArchiveTask.destinationDir property has been deprecated. This is scheduled to be removed in Gradle 7.0. Please use the destinationDirectory property instead. See https://docs.gradle.org/6.5/dsl/org.gradle.api.tasks.bundling.AbstractArchiveTask.html#org.gradle.api.tasks.bundling.AbstractArchiveTask:destinationDir for more details.
        at FlutterPlugin$_addFlutterTasks_closure17$_closure37.doCall(/Users/teddy/flutter/packages/flutter_tools/gradle/flutter.gradle:763)
        (Run with --stacktrace to get the full stack trace of this deprecation warning.)
The AbstractArchiveTask.archiveName property has been deprecated. This is scheduled to be removed in Gradle 7.0. Please use the archiveFileName property instead. See https://docs.gradle.org/6.5/dsl/org.gradle.api.tasks.bundling.AbstractArchiveTask.html#org.gradle.api.tasks.bundling.AbstractArchiveTask:archiveName for more details.
        at FlutterPlugin$_addFlutterTasks_closure17$_closure37.doCall(/Users/teddy/flutter/packages/flutter_tools/gradle/flutter.gradle:764)
        (Run with --stacktrace to get the full stack trace of this deprecation warning.)

FAILURE: Build failed with an exception.

Android Gradle 버전 수정

오류를 검색하다보니, 현재 Android Gradle 버전과 플러그인 버전이 맞지 않는것을 확인(stackoverflow)

버전 확인: https://developer.android.com/studio/releases/gradle-plugin#updating-plugin

Gradle 버전과 플러그인 버전을 수정하니 아래와 같은 오류가 출력 됨.

뭔가 facebook-applinks를 사용하기위해 load Maven meta-data를 시도하는데 https://google.bintray.com/exoplayer/com/facebook/android/facebook-applinks/maven-metadata.xml Received status code 502 from server: Bad Gateway가 출력 됨.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Could not resolve com.facebook.android:facebook-applinks:[8,9).
     Required by:
         project :app
      > Failed to list versions for com.facebook.android:facebook-applinks.
         > Unable to load Maven meta-data from https://google.bintray.com/exoplayer/com/facebook/android/facebook-applinks/maven-metadata.xml.
            > Could not get resource 'https://google.bintray.com/exoplayer/com/facebook/android/facebook-applinks/maven-metadata.xml'.
               > Could not GET 'https://google.bintray.com/exoplayer/com/facebook/android/facebook-applinks/maven-metadata.xml'. Received status code 502 from server: Bad Gateway

* 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.

* Get more help at https://help.gradle.org

BUILD FAILED in 2m 22s
[!] Gradle threw an error while downloading artifacts from the network. Retrying to download...

Flutter 패키지 버전 업그레이드

수많은 구글링과 다양한 방법을 시도해봤는데, 결론은 Flutter 패키지가 오래되서 호환이 안되는 문제였음.
아래 명령어를 수행하여, 모든 버전을 업데이트 수행

버전 차이가 많이나면, 문법이나 함수가 변경되어서 오류가 많이 발생할 수 있음
pub upgrade에 여러가지 옵션이 제공되니 확인바람

flutter pub upgrade --major-versions

나의 경우는 firebase의 몇개 패키지가 버전이 매우 낮아서 발생한 문제로 보임.
대부분의 코드에서 오류는 발생하지 않았고, firebase_dynamic_links 에서 많은 오류가 발생하였음.

Android Build 성공 🙌 🙌


기타

Gradle 버전이 정상적으로 올라가지 않을때

cd android
./gradlew clean
./gradlew build

Flutter 패키지가 정상적으로 업데이트 되지 않을때

flutter clean
pubspec.lock 삭제
flutter run
profile
Frontend Developer

0개의 댓글