JS: Error in firebase.logEvent: Error: java.lang.NullPointerException: null reference
JS: com.google.android.gms.common.internal.zzab.zzy(Unknown Source)
JS: com.google.android.gms.measurement.internal.zzx.zzdo(Unknown Source)
JS: com.google.firebase.analytics.FirebaseAnalytics.getInstance(Unknown Source)
JS: com.tns.Runtime.callJSMethodNative(Native Method)
JS: com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:862)
There are no null's being passed in so I'm assuming this is coming from the plugin... will look.
Curious to learn what it is. I can imagine this could happen with 3.6.0, less with 3.6.1. Can you post the snippet that logs the event?
@EddyVerbruggen occurs after I do this:
firebase.analytics.logEvent({
key: 'MY_ACTION',
properties:[
{
key: 'category',
value: 'my_category'
},
{
key: 'label',
value: 'my_label'
},
{
key: 'value',
value: 'my_value'
}
]
}).then(() => {
});
^ causes this immediate crash:
JS: Error in firebase.logEvent: Error: java.lang.NullPointerException: null reference
JS: com.google.android.gms.common.internal.zzab.zzy(Unknown Source)
JS: com.google.android.gms.measurement.internal.zzx.zzdo(Unknown Source)
JS: com.google.firebase.analytics.FirebaseAnalytics.getInstance(Unknown Source)
Hmm, yeah puzzled by this one. Am I missing something obvious?
Nvm!! Ah... it's parameters ... not properties ...
Just wanted to show you 馃槈
In your defence it took me a while to choose between those two param names..
Well shoot, it's stiiiilll crashing. :(
Noooooooooo!
You 谩re on 3.6.1, right?
I am yeah... just Android only. Works fine in iOS... pretty puzzling.
https://github.com/EddyVerbruggen/nativescript-plugin-firebase/blob/master/firebase.android.js#L303
currentContext must be where the issue is coming from since stack says:
com.google.firebase.analytics.FirebaseAnalytics.getInstance(Unknown Source)
? Unknown Source?
That has bitten me before in other plugins.. that context.. it seems to get nulled sometimes. Time to investigate!
It must be the single quotes!
LOL! right.
maybe try this: app.android.currentContext || app.android.context ...
Does appModule.android.context work for your case?
building now... lemme see
Worked like a charm 馃憤
com.google.firebase.analytics.FirebaseAnalytics.getInstance(app.android.currentContext || app.android.context).logEvent(action, bundle);
Thanks for looking into it. You may run into a similar issue with other methods as well so I will investigate this further shortly!
Thanks @EddyVerbruggen yep been bit by similar kind of thing with {N} android projects...Hope similar conditional will help resolve throughout!
I'm settling on your proposed patch. This {N} issue seems to also advice to use context if currentContext is causing trouble. Let's just ignore this oddity and move on :)
app.android.currentContext || app.android.context||app.android.foregroundActivity||utils.ad.getApplicationContext() nothing worked..
how to pass the current Activity context...
Most helpful comment
It must be the single quotes!