Search code examples
androidcordovagradleandroid-gradle-plugingradle-plugin

Define Android Gradle Plugin Version when Building with Cordova


When building my Android project with Cordova, I get the following message when opening in Android Studio:

enter image description here

My build.gradle file reflects the plugin discrepancy (although the Gradle version defined is correct):

dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0'
    }

I'd like to know if there is a way to configure Cordova to explicitly define an Android Gradle Plugin version.


Solution

  • The Android Gradle plugin version is hard-coded into the build.gradle template in cordova-android.

    If you install the platform off the master branch, you can see it's using a higher version (3.2.0) than the most recent npm release [email protected] which is configured for 3.0.1.

    To install directly from the master branch:

    cordova platform add https://github.com/apache/cordova-android
    

    If you want to use the very latest version, you could fork the cordova-android repo, pin the version you want in the build.gradle template, then install the plugin directly from your forked repo:

    cordova platform add https://github.com/my_github_username/cordova-android