简体   繁体   中英

jCenter returns 502 Bad Gateway

I am trying to build my project but it seems the jcenter is down.

$ cd android $ sudo./gradlew assembleRelease

> Task :app:lintVitalRelease FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:lintVitalRelease'.
> Could not resolve all artifacts for configuration ':react-native-community_masked-view:releaseRuntimeClasspath'.
   > Could not resolve com.facebook.react:react-native:+.
     Required by:
         project :react-native-community_masked-view
      > Failed to list versions for com.facebook.react:react-native.
         > Unable to load Maven meta-data from https://jcenter.bintray.com/com/facebook/react/react-native/maven-metadata.xml.
            > Could not HEAD 'https://jcenter.bintray.com/com/facebook/react/react-native/maven-metadata.xml'. Received status code 502 from server: Bad Gateway

JCenter is deprecated and now READ ONLY. And it is getting offline sometimes causing issues with builds.

First of all, you need to update your build.gradle file to use mavenCentral() replacing Jcenter()

In case is a library (eg node_modules/react-native-appsflyer), pointing to Jcenter, that is giving you an error... I would advise you to check the library giving you an error has updated a new version with a fix. In case so, update to the new version to get the changes.

In case no, if you are building in React-native using npm packages, you could potentially take advantage of patch-package library.

Sometimes, the libraries have not yet released the update removing JCenter from build.gradle.

In this case, you can apply the changes yourself using the Patch Package library. Documentation added in the end for reference.

  1. Go to node_modules/library-with-error/android/build.gradle
  2. Change jcenter() to mavenCentral()
  3. Run: npx patch-package library-with-error
  4. Git add, commit and push

Important: In case of dependencies (pom, jar) are not added to Maven, here are instructions on how to add: https://maven.apache.org/repository/guide-central-repository-upload.html . Add that to the PR with discussions to collaborate.

Notes:

  • Add --use-yarn to patch-package command in case your project uses Yarn .
  • Documentation using Patch package .

JFrog will keep JCenter as a read-only repository indefinitely. JCenter users and the community can continue to rely on JCenter as a reliable mirror for Java packages. You may visit https://www.jfrog.com/confluence/display/JFROG/JFrog+Bintray+Migration+Guide for further details.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM