JFrog announced in this article that JCenter would be deprecated in May of 2021. Although JFrog would later update this article to indicate that repositories hosted in JCenter would remain accessible in a read-only state, there have been notable occurrences of service issues towards the end of 2021. For example, dl.bintray.com became inaccessible to users at the start of December 2021 as any attempts to access repositories from this sub-domain will return a 502 Bad Gateway error. As of February 2022, this issue has not been addressed by JFrog. Because it is not clear what the future holds for JCenter repositories, this guide will walk you through the process to find JCenter related repositories in your android project in the event that other JCenter related resources become inaccessible.
When an Android project requires a dependency, the dependency is defined within the build.gradle file found within the app directory of the android project:
Gradle will attempt to find the repositories associated with these dependencies by referring to the list of repositories defined within the top level build.gradle file:
In this example, gradle will first attempt to find a dependency within the Google Maven repository. Gradle will then attempt to find the dependency in the JCenter repository if the dependency could not be found in the Google Maven repository. Therefore, replacing jcenter() with mavenCentral() in the top level build.gradle file may be sufficient to migrate from JCenter.
The repository object may also contain URLs pointing to JCenter resources. In this case, the repository containing these URLs should also be deleted. In both cases, it is assumed that the android project only contains dependencies that are known to have been migrated from JCenter to Maven. Running the following gradle command can be used to confirm if this is the case.
./gradlew assemble assembleDebugUnitTest assembleAndroidTest --refresh-dependencies
If there are dependencies that have not been migrated from JCenter to Maven, then you will receive an error message like the one shown below
* What went wrong:
Could not determine the dependencies of task ':app:assembleDebug'.
If this error message does appear after updating the build.gradle file, then you will need to review the error messages that appear after the above message to determine the dependency that was not migrated to mavenCentral. This dependency would then need to be updated to a version found in Maven or replaced entirely.
It is also possible to obtain a list of dependencies associated with a JCenter resource by running a gradle scan on the project initiated from the command line:
gradle build --scan
This method will require a valid email address for Gradle to send a link to the scan results. With these scan results, you can navigate to “Dependencies” to obtain a list of all dependencies found within the android project.
At the top of the dependencies list, there is a summary of the dependencies which includes a link to group the dependencies by repository.
Using this method also reveals any nested dependencies which would have referenced JCenter that would not have been immediately clear by reviewing the build.gradle files directly.
Comments
0 comments
Article is closed for comments.