Capacitor: Cordova Google analytics: Java exception was raised during method invocation

Created on 21 May 2019  ·  3Comments  ·  Source: ionic-team/capacitor

Description of the problem:
Using https://www.npmjs.com/package/cordova-plugin-google-analytics plugin causes app crash.

Affected platform

  • [X] Android
  • [ ] iOS
  • [ ] electron
  • [ ] web

OS of the development machine

  • [ ] Windows
  • [X] macOS
  • [ ] linux

Other information:
Maybe it is related to https://github.com/ionic-team/capacitor/issues/1142 but not sure what to change to make it work with google analytics.

Capacitor version: 1.0.0-beta.24

Steps to reproduce:
1) Add "cordova-plugin-google-analytics": "^1.8.6", plugin
2) Just register analytics

window.analytics.startTrackerWithId(AppConst.gaIdMobile);

3) It throws error

Screenshot 2019-05-21 at 10 06 52 PM

Most helpful comment

It's because the analytics plugin uses an old play-services-analytics version.

I got it working by adding this to the app's build.gradle file in the dependencies section to force it to use latest version:

implementation "com.google.android.gms:play-services-analytics:16.0.8"

All 3 comments

Can you provide a sample app?

Here it is.

Just run the application on android. It will try to register analytics from main.js and it will just throw the error.

https://github.com/stripathix/ionic-vue

It's because the analytics plugin uses an old play-services-analytics version.

I got it working by adding this to the app's build.gradle file in the dependencies section to force it to use latest version:

implementation "com.google.android.gms:play-services-analytics:16.0.8"

Was this page helpful?
0 / 5 - 0 ratings