androidmavenjcenter

Is JCenter down permanently (31 Oct)?


Moderator Note: This appears to be a service outage. Stack Overflow cannot provide support for this issue

   > Failed to list versions for com.google.http-client:google-http-client-android.
         > Unable to load Maven meta-data from https://jcenter.bintray.com/com/google/http-client/google-http-client-android/maven-metadata.xml.
            > Could not HEAD 'https://jcenter.bintray.com/com/google/http-client/google-http-client-android/maven-metadata.xml'.
               > Read timed out

I was trying to build an Android app, but I got the above error. When I connect to “https://jcenter.bintray.com/com/google/http-client/google-http-client-android/maven-metadata.xml”, an nginx 403 error appears. Is JCenter down? What should I do?


Solution

  • Update: Nov 8, 2022

    There is yet another incident. Follow the incident here


    tldr;

    Yes. JCenter is down right now. But there is a way to fix the issue. JCenter was sunset a while ago and remained available in read-only mode. So far there isn't any update on when it will be available again. Depending your situation, you have quick or not so-quick options for you.


    Where can I check status?

    New incident is reported here. Check this out.

    As @Adrian mentioned in a comment, you can check the status of the current incident on Gradle's incident status page. The status shows "Resolved", but I still can’t make the project. So I wonder if that status page just shows the impact of JCenter on Gradle Plugin Portal and not the status of JCenter in general.


    What can I do now?

    Recommended Update:

    Now that incident is resolved by updating gradlePluginPortal to serve as JCenter mirror (almost), it's highly possible that adding following repositories before jcenter() should resolve the issue:

    google()
    mavenCentral()
    gradlePluginPortal() 
    

    Temporary solution:

    Toggle offline mode of Gradle as shown below. This will work for the local machine, but it won’t work for CI though.

    Toggle offline mode option

    Robust solution:

    It's always a good idea to move away from a deprecated service. Most active libraries are now hosted on other popular repositories like the Google repository, Maven Central or the Gradle plugin repository.

    To add those repositories in your project, add following in repositories block (you might already have those). Order matters. Make sure to put them before jcenter() this tells Gradle to look into other repositories before trying to pull from jcenter().

    Tip: Do a global search for jcenter() and ensure every repository block that contains jcenter() has these other repositories.

     repositories {
        ...
        google()
        mavenCentral()
        gradlePluginPortal() 
        jcenter()
        ...
     }
    

    Do Gradle sync and clean build and see if that works.


    Didn't that work?

    Don't worry (yet). This is common. The above solution won’t work alone for some situations:

    1. When moved from jcenter() to other repository (like mavenCentral()), authors decided to update the version number. This simply means you need to update the version of that dependency to fetch it from other repository. Look for the library that shows up as unavailable in failed build log. Find its GitHub or development documentation to check the latest version. Gradle Sync + clean build.

    2. The repositories that we just added are popular ones, but they are not the only ones. When authors of library had to switch from JCenter to somewhere else, they did not choose one of these. In such cases, check the GitHub page or developers documentation. Usually authors put the required repository on those pages. If you find that repository is not present in your project, add it. Gradle Sync + clean build.

      • Beware: Some authors chose repository options like jitpack.io largely because it was quick and easier than others. But you should be aware of concerns with that. Melix from Gradle summarizes the concerns with jitpack.io. Because of potential security issues, I recommend to consult team and security expert before adding that.
    3. Well, now it's time for little worry. It's highly possible that you are using some library that is deprecated or no longer maintained. Find GitHub page of the library and see if author declared it deprecated or no-longer maintained in readme. You can even check when it got last commit. If it was a while ago, it means it's no longer maintained and author did not care to move library from jcenter() to any other repo.

      • Go to GitHub issues of the repository. Someone must have posted question regarding plan to move from jcenter. If you are in luck, someone might even have created fork and hosted that fork somewhere else. For example, I use spanny in one of the projects and author did not move it. GustavoRoss cared enough to fork and move.
      • No one forked and moved? Then you have two options.
        1. Look for an alternate active library that does the same for you. Of course this is time consuming, but again a good idea to move away from deprecated resource.
        2. If you don't have time to integrate new library or no other library exist, then be the hero and make fork of GitHub project and move.
    4. But hey, I don't remember putting library in question in my code base? This means, it's a transitive dependency (a dependency of your direct dependency). Again check, latest version of your direct dependency and hopefully new version has fixed this.

    How can I check a direct and transitive dependency?

    Build log annotated screenshot

    Hopefully by this point you got the build working. If not, then hope for JCenter to come back soon and start planning to move away from it.