Search code examples
androidcordovagradlephonegap

Force dependencies for gradle in cordova config.xml


I'm trying to add exact dependencies, but it looks like all of them ignored in /platforms/android/project.properties and /platforms/android/build.gradle

config.xml

<widget>
    <platform name="android">
        <framework src="com.google.android.gms:play-services-analytics:9.8.0" />
        <framework src="com.google.gms.google-services:9.8.0" />
    </platform>
    <engine name="android" spec="6.2.3" />
    <engine name="cordova" spec="6.5.0" />
    <engine name="npm" spec="4+" />
</widget>

The output is:

project.properties

android.library.reference.1=CordovaLib
cordova.system.library.1=com.google.android.gms:play-services-analytics:+

build.gradle

dependencies {
    compile "com.google.android.gms:play-services-analytics:+"
}

Solution

  • You cannot add <framework> tags in config.xml: they are supported in plugin.xml but not config.xml.

    However, to achieve what you are trying to do (force Play Services version to v9), you can use cordova-android-play-services-gradle-release:

    cordova plugin add https://github.com/dpa99c/cordova-android-play-services-gradle-release#v9
    

    That branch contains a bit of Gradle config to override the version to v9.