I am trying to remove jcenter()
from my project because it is deprecated. But I am using com.google.android.libraries.places:places:2.4.0
dependency that is currently the latest version, that is outlined in official docs. And interesting thing, that when I try to build project it fails, because it can't find dependency com.android.volley:volley:1.1.1
. I do not use this dependency in my project directly, but I found, that it is transitive dependency inside places
library.
When I execute gradlew app:dependencies
I can see such situation:
+--- com.google.android.libraries.places:places:2.4.0
| +--- androidx.appcompat:appcompat:1.0.0 -> 1.3.1 (*)
| +--- androidx.cardview:cardview:1.0.0 (*)
| +--- androidx.fragment:fragment:1.1.0 -> 1.3.6 (*)
| +--- androidx.lifecycle:lifecycle-extensions:2.1.0 -> 2.2.0 (*)
| +--- androidx.recyclerview:recyclerview:1.0.0 -> 1.2.1 (*)
| +--- com.android.volley:volley:1.1.1 FAILED
| +--- com.google.android.datatransport:transport-api:2.2.0 -> 3.0.0 (*)
| +--- com.google.android.datatransport:transport-backend-cct:2.3.0 -> 3.0.0 (*)
| +--- com.google.android.datatransport:transport-runtime:2.2.3 -> 3.0.0 (*)
| +--- com.google.android.gms:play-services-base:17.2.1 -> 17.5.0 (*)
| +--- com.google.android.gms:play-services-basement:17.0.0 -> 17.5.0 (*)
| +--- com.google.android.gms:play-services-location:17.0.0 -> 18.0.0 (*)
| +--- com.google.android.gms:play-services-maps:17.0.0
| | +--- androidx.fragment:fragment:1.0.0 -> 1.3.6 (*)
| | +--- com.google.android.gms:play-services-base:17.0.0 -> 17.5.0 (*)
| | \--- com.google.android.gms:play-services-basement:17.0.0 -> 17.5.0 (*)
| +--- com.google.android.gms:play-services-tasks:17.0.0 -> 17.2.0 (*)
| +--- com.google.auto.value:auto-value-annotations:1.6.2
| \--- com.google.code.gson:gson:2.8.5 -> 2.8.7
So, com.google.android.libraries.places:places:2.4.0
uses outdated library com.android.volley:volley:1.1.1
. Interesting thing, that com.android.volley
is hosted on mavenCentral
only starting from 1.2.0
version. And 1.1.1
version is available ONLY in Bintray
: https://mvnrepository.com/artifact/com.android.volley/volley/1.1.1
My top-level config:
buildscript {
ext.kotlin_version = '1.5.21'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.0.0'
classpath 'com.google.gms:google-services:4.3.10'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.7.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
So, how can I migrate from jcenter
when even Google didn't? Or am I missing something?
All Android developers should switch off of JCenter in order to continue getting updates to libraries and SDKs that they use. OneSignal and many other libraries are already available on Maven Central, so migrating is a safe and simple process.
Summary: After February 1st, 2022 jcenter() will not work anymore. According to this Gradle blog post: Gradle 7.0 will deprecate the use of jcenter() to resolve dependencies. You will still be able to use JCenter as a repository, but Gradle will emit a warning.
To do so, you must simply add mavenCentral() in your build. gradle file. Make sure to put mavenCentral() before JCenter so that the build script takes the up-to-date versions on mavenCentral in priority.
Your build may be affected by this shutdown in several ways: Gradle may not be able to download the dependencies used to compile, test or run your code. Gradle may not be able to download the dependencies used by plugins to configure your build.
This doesn’t just mean we can’t remove jcenter () from our projects yet. But keeping jcenter () as a repository could cause us to add even more jcenter () only dependencies in the future! This will restrict Gradle to only use jcenter () for this single dependency.
For each jcenter () dependency you still have, I recommend opening a public Github issue to request the library author to migrate. With this solution, Gradle will first look for the artifact in the google () repository, then in mavenCentral () and finally in jcenter () if the artifact is on the explicit allow list.
The Google Play Services version of the Places SDK for Android (i.e. com.google.android.gms:play-services-places) was turned off on July 29, 2019, and is no longer available. A new version of the Places SDK for Android is now available.
✔️ Sync Gradle by pressing "Sync Now" in Android Studio. Step 2: Fully migrate off of JCenter. This section is optional until February 1, 2022 but we recommend following it today since JCenter has been less reliable as it sunsets. The following steps will also allow you to discover any other dependencies you have on JCenter.
For now you can manually include the Volley dependency separately and exclude the 1.1.1 version from the Places dependency.
implementation('com.google.android.libraries.places:places:2.4.0') {
exclude group: 'com.android.volley'
}
implementation 'com.android.volley:volley:1.2.0'
As you pointed out Volley is now on Maven Central so you'd also need to include the mavenCentral()
repository.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With