How to extend cordova build.gradle to change repositories

Viewed 1655

Problem

Due to a problem with jcenter repository I need to instruct gradle to use use maven repository. I could fix the problem changing the file build.gradle:

Original:

//...
buildscript {
    repositories {
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
    //...
}
allprojects {
    repositories {
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
}
//...

Modified:

//...
buildscript {
    repositories {
        mavenCentral()
        maven {
            url "https://maven.google.com"
        }
        jcenter()
    }
    //...
}
allprojects {
    repositories {
        mavenCentral()
        maven {
            url "https://maven.google.com"
        }
        jcenter()
    }
}
//...

Since this file is not versioned, and per Cordova documentation, the way to extend build.gradle is to create a build-extras.gradle file, I've done so and have tried to add the same content I've modified in the build.gradle file, like:

build-extras.gradle

buildscript {
    repositories {
        mavenCentral()
        maven {
            url "https://maven.google.com"
        }
        jcenter()
    }
    //...
}
allprojects {
    repositories {
        mavenCentral()
        maven {
            url "https://maven.google.com"
        }
        jcenter()
    }
}

Question

To sum up, changing the build.gradle file works but placing the same diffed content in build-extras.gradle it does not. Is there something that I'm missing?

1 Answers
  1. Remove platforms and plugins folders (lets do everything from scrach so it's cleaner).

  2. Do ionic cordova platform add android

  3. Do cordova plugin add cordova-android-play-services-gradle-release --variable PLAY_SERVICES_VERSION=15.0.0 --fetch

  4. Now finally you can do ionic cordova run android or ionic cordova build android
Related