Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

Android analytics: Error in firebase.logEvent: Error: java.lang.NullPointerException: null reference #128

Closed
NathanWalker opened this issue Sep 9, 2016 · 21 comments
Labels

Comments

@NathanWalker
Copy link
Contributor

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.

@EddyVerbruggen
Copy link
Owner

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?

@NathanWalker
Copy link
Contributor Author

NathanWalker commented Sep 9, 2016

@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)

@NathanWalker
Copy link
Contributor Author

Hmm, yeah puzzled by this one. Am I missing something obvious?

@NathanWalker
Copy link
Contributor Author

Nvm!! Ah... it's parameters ... not properties ...

@EddyVerbruggen
Copy link
Owner

Just wanted to show you 😉

In your defence it took me a while to choose between those two param names..

@NathanWalker
Copy link
Contributor Author

Well shoot, it's stiiiilll crashing. :(

@NathanWalker NathanWalker reopened this Sep 9, 2016
@EddyVerbruggen
Copy link
Owner

Noooooooooo!

You áre on 3.6.1, right?

@NathanWalker
Copy link
Contributor Author

I am yeah... just Android only. Works fine in iOS... pretty puzzling.

@NathanWalker
Copy link
Contributor Author

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?

@EddyVerbruggen
Copy link
Owner

That has bitten me before in other plugins.. that context.. it seems to get nulled sometimes. Time to investigate!

@EddyVerbruggen
Copy link
Owner

It must be the single quotes!

@NathanWalker
Copy link
Contributor Author

LOL! right.

@NathanWalker
Copy link
Contributor Author

maybe try this: app.android.currentContext || app.android.context ...

@EddyVerbruggen
Copy link
Owner

Does appModule.android.context work for your case?

@NathanWalker
Copy link
Contributor Author

building now... lemme see

@NathanWalker
Copy link
Contributor Author

Worked like a charm 👍

@NathanWalker
Copy link
Contributor Author

com.google.firebase.analytics.FirebaseAnalytics.getInstance(app.android.currentContext || app.android.context).logEvent(action, bundle);

@EddyVerbruggen
Copy link
Owner

Thanks for looking into it. You may run into a similar issue with other methods as well so I will investigate this further shortly!

@NathanWalker
Copy link
Contributor Author

Thanks @EddyVerbruggen yep been bit by similar kind of thing with {N} android projects...Hope similar conditional will help resolve throughout!

EddyVerbruggen added a commit that referenced this issue Sep 10, 2016
@EddyVerbruggen
Copy link
Owner

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 :)

EddyVerbruggen added a commit that referenced this issue Apr 18, 2017
@priyangamani
Copy link

app.android.currentContext || app.android.context||app.android.foregroundActivity||utils.ad.getApplicationContext() nothing worked..
how to pass the current Activity context...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants