androidgradlecapacitorjcenter

Could not find org.apache.cordova:framework:7.0.0 after removing jcenter() in Android


My project is in Ionic 5 and just upgraded to Capacitor 3. After this upgrade I am am getting the following error.

Please remove usages of `jcenter()` Maven repository from your build scripts and migrate your build to other Maven repositories.

So, as per the suggested solutions from different forums I first added mavenCentral() on top of center() in build.gradle and build the project. This was successful. Then I removed the jcenter(). After this build I am getting the following error.

Execution failed for task ':app:checkDebugAarMetadata'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Could not find org.apache.cordova:framework:7.0.0.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/org/apache/cordova/framework/7.0.0/framework-7.0.0.pom
       - https://repo.maven.apache.org/maven2/org/apache/cordova/framework/7.0.0/framework-7.0.0.pom
       - file:/Users/**/android/capacitor-cordova-android-plugins/src/main/libs/framework-7.0.0.jar
       - file:/Users/**/android/capacitor-cordova-android-plugins/src/main/libs/framework.jar
       - file:/Users/**/android/app/libs/framework-7.0.0.jar
       - file:/Users/**/android/app/libs/framework.jar
     Required by:
         project :app > project :capacitor-android
         project :app > project :capacitor-cordova-android-plugins

Is there a way I can add the missing depedency and remove jcenter().


Solution

  • cordova-android 10 is now published on maven, so it's possible to remove jcenter entries from you Capacitor project.

    First replace both jcenter() entries with mavenCentral() in projectName/android/build.gradle file.

    Then increase minSdkVersion value to 22 and cordovaAndroidVersion version to '10.1.1' in projectName/android/variables.gradle file.

    Finally sync gradle and you should be able to run your app.

    OLD ANSWER:

    cordova is only distributed in jcenter at the moment, so you can't remove the jcenter() entry from your build.gradle

    The

    Please remove usages of jcenter() Maven repository from your build scripts and migrate your build to other Maven repositories.

    should be just a warning for now, not an error.