Home > Back-end >  What is the correct way of changing jcenter to mavenCentral?
What is the correct way of changing jcenter to mavenCentral?

Time:08-24

I am working on an old project and Android Studio recommended me to update to mavenCentral(). I had this code:

buildscript {
    repositories {
        google()
        jcenter()
        
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:7.2.1'
        classpath 'com.google.gms:google-services:4.3.13
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven { url "https://jitpack.io" }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

And I have changed it to this one:

buildscript {
    repositories {
        google()
        mavenCentral()
        
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:7.2.1'
        classpath 'com.google.gms:google-services:4.3.13
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
        maven { url "https://jitpack.io" }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

Now my question is, is it enough just changing jcenter() for mavenCentral() to update from jcenter to mavenCentral like I have done or should I make something else to update from jcenter to mavenCentral?

CodePudding user response:

Yeah, it should be enough just changing jcenter() to mavenCentral() if your project is building successfully. If not then you need to check what missing library in mavenCentral is failing your build. Then learn which ways you have to fix it, for some libs you will need to use jitpack, for others upgrade to a version (where the author migrated it to mavenCentral), or host it locally in the project, etc.

Also, don't forget to do it for build.gradle in your other modules (not only root).

  • Related