在 cordova config.xml 中强制依赖 gradle

Force dependencies for gradle in cordova config.xml

我正在尝试添加确切的依赖项,但在 /platforms/android/project.properties[=36= 中似乎所有这些都被忽略了].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>

输出为:

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:+"
}

您不能在 config.xml 中添加 <framework> 标签:它们是 supported in plugin.xml but not config.xml.

但是,要实现您的目标(将 Play 服务版本强制为 v9),您可以使用 cordova-android-play-services-gradle-release:

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

该分支包含 bit of Gradle config 以将版本覆盖到 v9。