使用Gradle将Google服务添加到Cordova Android应用程序

3
我正在尝试将Google Analytics集成到我的Cordova Android应用程序中。我使用了https://developers.google.com/analytics/devguides/collection/android/v4/的指南,但是当我想要添加时


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.

你解决了这个问题吗? - andrewoodleyjr
1个回答

2
我终于找到了解决方案:
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>

2) 创建ga.gradle文件

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

6
在使用 google-services:3.0.0 时,出现以下错误:Error: A problem occurred configuring root project 'android'。> Could not generate a proxy class for class com.google.gms.googleservices.GoogleServicesTask. - Joshua

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接