使用Gradle向Cordova Android应用程序添加谷歌服务

使用Gradle向Cordova Android应用程序添加谷歌服务,android,cordova,google-analytics,Android,Cordova,Google Analytics,我正在尝试将谷歌分析集成到我的Cordova Android应用程序中。我使用了来自的指南,但当我想添加 apply plugin:'com.google.gms.google-services' 它在build.gradle中抛出错误: A problem occurred evaluating root project 'android'. Failed to apply plugin [id 'com.google.gms.google-services'] Plugin with id

我正在尝试将谷歌分析集成到我的Cordova Android应用程序中。我使用了来自的指南,但当我想添加

apply plugin:'com.google.gms.google-services'
它在build.gradle中抛出错误:

A problem occurred evaluating root project 'android'.
Failed to apply plugin [id 'com.google.gms.google-services']
Plugin with id 'com.google.gms.google-services' not found.

我终于找到了解决办法:

1) 我必须设置plugin.xml以使用自定义ga.gradle文件进行构建

 <platform name="android">
         <framework src="src/android/ga.gradle" custom="true" type="gradleReference" />
         <framework src="com.google.android.gms:play-services-analytics:8.1.0"/>
         <resource-file src="src/android/google-services.json" target="google-services.json" />
           ...
     </platform>

您曾经解决过这个问题吗?当使用
googleservices:3.0.0
时,出现了以下错误:
错误:配置根项目“android”时出现问题。>无法为com.google.gms.googleservices.GoogleServicesTask类生成代理类。
buildscript {
    repositories {
        jcenter()
    }

    dependencies {
        classpath 'com.google.gms:google-services:1.4.0-beta6'
    }
}

// apply plugin: 'com.google.gms.google-services'
// class must be used instead of id(string) to be able to apply plugin from non-root gradle file
apply plugin: com.google.gms.googleservices.GoogleServicesPlugin