Upgrade Your Android Project from JCenter to Maven Central
Tags: developer, android, news
Published: 2021-04-20 05:46:30

---
title: Upgrade Your Android Project from JCenter to Maven Central
published: true
date: 2021-03-23 19:27:33 UTC
tags: developer,android, news
canonical_url: https://onesignal.com/blog/android-migrate-jcenter-to-maven-central/
---

 ![Upgrade Your Android Project from JCenter to Maven Central](https://onesignal.com/blog/content/images/2021/03/android-developer-support.jpg)

Google's Android Studio defaults to the JCenter repository for non-Google artifacts. Unfortunately, JFrog, the maintainers of JCenter, [recently announced](https://dev.to/jbaruch/into-the-sunset-on-may-1st-bintray-jcenter-gocenter-and-chartcenter-pkk-temp-slug-2941368) that they are soon sunsetting JCenter.

Breaking down [JFrog's announcement](https://dev.to/jbaruch/into-the-sunset-on-may-1st-bintray-jcenter-gocenter-and-chartcenter-pkk-temp-slug-2941368), this means the following for Android developers for their app's dependencies:

- **March 31st 2021 -** Libraries in JCenter will no longer be updated. 
- **February 1, 2022** - JCenter will be completely shut down.

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](https://mvnrepository.com/repos/central), so migrating is a safe and simple process.

**Follow the steps below to make the switch:**

## Step 1: Add Maven Central to your project to ensure OneSignal continues to get updated.

1. Open your root `build.gradle`
2. Find lines that say `jcenter()` and add `mavenCentral()` before each of them _(Make sure to add `mavenCenteral()` in both spots where `jcenter()` is found.)_

After this change, your `build.gradle` should look like this:

<!--kg-card-begin: markdown-->
```
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        google()
        mavenCentral() // New line
        jcenter()
       // NOTE: Keep any other entries you may have had here
    }
    dependencies {
        classpath "com.android.tools.build:gradle:4.1.2"
        //... no changes here
    }
}

allprojects {
    repositories {
        google()
        mavenCentral() // New line
        jcenter()
       // NOTE: Keep any other entries you may have had here
    }
}

```
<!--kg-card-end: markdown-->

✔️ 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](https://status.bintray.com/incidents/ctv4bdfz08bg) as it sunsets. The following steps will also allow you to discover any other dependencies you have on JCenter.

You may have noticed that adding Maven Central before JCenter means Maven Central will be used by default, and JCenter will still be used as a fallback.

If you attempt to remove `jcenter()` completely today from your Android project, you may get the following error.

<!--kg-card-begin: markdown-->
```
> Could not resolve all artifacts for configuration ':classpath'.
   > Could not find org.jetbrains.trove4j:trove4j:20160824.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/org/jetbrains/trove4j/trove4j/20160824/trove4j-20160824.pom
       - https://repo.maven.apache.org/maven2/org/jetbrains/trove4j/trove4j/20160824/trove4j-20160824.pom
     Required by:
         project : > com.android.tools.build:gradle:4.1.2 > com.android.tools.build:builder:4.1.2 > com.android.tools:sdk-common:27.1.2

```
<!--kg-card-end: markdown-->

The reason for this error is that the Android Core dependency still requires JCenter.

Android Studio 4.1.2 and AGP (Android Gradle Plugin) still require a version of a dependency (trove4j) that is only on JCenter.

- _[This is solved in AGP 4.2.0](https://issuetracker.google.com/issues/109894262#comment7), but this is still in beta and requires Android Studio 4.2 beta or newer._

To fix the missing `trove4j` error, you can force an upgrade to a newer version that is available on Maven Central by adding the following to the bottom of your root `build.gradle`.

<!--kg-card-begin: markdown-->
```
// Temporary workaround for missing trove4j when removing jcenter() until you can upgrade to "com.android.tools.build:gradle:4.2.0"
buildscript {
    configurations.all {
        resolutionStrategy {
            eachDependency {
                // https://issuetracker.google.com/issues/109894262#comment9
                if (requested.group == "org.jetbrains.trove4j" && requested.name == "trove4j" && requested.version == "20160824") {
                    useTarget("org.jetbrains.intellij.deps:trove4j:1.0.20181211")
                }
            }
        }
    }
}

```
<!--kg-card-end: markdown-->

_[Source](https://issuetracker.google.com/issues/109894262#comment11)_

### If you encounter other "could not resolve" errors:

You may find that not all libraries or SDKs in your project are on Maven Central.

If you still see build errors after removing `jcenter()`, please check your build log and contact the vendors of those dependencies on to get guidance on their migration strategy. Keep in mind that JCenter will no longer work after Feb 1, 2022.

# OneSignal Resources & Support

To continue getting OneSignal Android SDK updates after March 31, 2021, make sure to add Maven Central to your project by following the above guide. [OneSignal is already hosted on Maven Central](https://search.maven.org/artifact/com.onesignal/OneSignal), including the latest OneSignal SDK and all previous versions.

If you have any OneSignal issues with the upgrade you can contact [OneSignal support](https://app.onesignal.com/)[via the dashboard](https://app.onesignal.com/), or [post your question on this GitHub issue](https://github.com/OneSignal/OneSignal-Android-SDK/issues/1293).