I'm trying to integrate Google Analytics into my Cordova Android app. I have used guide from https://developers.google.com/analytics/devguides/collection/android/v4/, but when i want to add
apply plugin:'com.google.gms.google-services'
into build.gradle it throws error:
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.
I finally found a solution:
1) I had to setup plugin.xml to use custom ga.gradle file for build
<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) Create ga.gradle file
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With