samzilverberg/cordova-mixpanel-plugin

No virtual method getInstanceId()

cyrilgandon opened this issue · 4 comments

Since upgrading the plugin from 4.4.1 to 4.6.2, we noticed a lot less event from Android.
Here are the log.

Error

java.lang.NoSuchMethodError: No virtual method getInstanceId()Lcom/google/android/gms/tasks/Task; 
in class Lcom/google/firebase/iid/FirebaseInstanceId; 
or its super classes (declaration of 'com.google.firebase.iid.FirebaseInstanceId'
appears in /data/app/com.brand.app-M4KXFAJ97TUlwaipUMGykQ==/base.apk)

Stacktrace

at com.mixpanel.android.mpmetrics.MixpanelFCMMessagingService.init(MixpanelFCMMessagingService.java:117)
at com.mixpanel.android.mpmetrics.MixpanelAPI.getInstance(MixpanelAPI.java:423)
at com.mixpanel.android.mpmetrics.MixpanelAPI.getInstance(MixpanelAPI.java:369)
at com.samz.cordova.mixpanel.MixpanelPlugin.handleInit(MixpanelPlugin.java:207)
at com.samz.cordova.mixpanel.MixpanelPlugin.execute(MixpanelPlugin.java:103)
at org.apache.cordova.CordovaPlugin.execute(CordovaPlugin.java:98)
at org.apache.cordova.PluginManager.exec(PluginManager.java:132)
at org.apache.cordova.CordovaBridge.jsExec(CordovaBridge.java:57)
at org.apache.cordova.engine.SystemExposedJsApi.exec(SystemExposedJsApi.java:41)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:325)
at android.os.Looper.loop(Looper.java:142)
at android.os.HandlerThread.run(HandlerThread.java:65)

After that failed initialization, every time we try to send event, we got

MIXPANEL PLUGIN: you must initialize mixpanel first using "init" action
CordovaPlugin: Attempted to send a second callback for ID: Mixpanel1898653301
CordovaPlugin: Result was: "Invalid action"

Any idea why? Is this linked to https://github.com/mixpanel/mixpanel-android/releases/tag/v5.5.0?
As a consumer of the plugin, do we have to change something in our conf?

Potentially linked issue: mixpanel/mixpanel-android#594

Our conf

"cordova-plugin-mixpanel": {
        "PLAY_SERVICES_VERSION": "11.0.1",
        "FIREBASE_VERSION": "11.0.1"
},

Given this comment: mixpanel/mixpanel-android#594 (comment)

In case someone encounters this problem in the future, make sure you are using firebase version 16.2.0 or higher

I guess that is my problem. Maybe it is worth to add it to the README, something like

requires FIREBASE_VERSION >16.2.x

Also, the example is

cordova plugin add cordova-plugin-mixpanel --variable PLAY_SERVICES_VERSION="11.8.0"

That is the version of Dec 18, 2017, maybe update this also.

ty for finding out that minimum firebase version requirement.
that would be good to document in the README.

will also update the example usage as well to use a more recent version while at it.
as far as i can see it looks like 17.0.0 is one of the latest.

added the info with this commit:
5066824