Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullPointerException on FirebaseInstallations.registerFidWithServer #1787

Closed
francescocervone opened this issue Jul 20, 2020 · 21 comments
Closed
Assignees
Labels
firebase-installations Firebase Installations service needs-info

Comments

@francescocervone
Copy link

Environment

  • Android Studio version: 3.6.3
  • Firebase Component: firebase-analytics, firebase-messaging, firebase-config, firebase-crashlytics -> firebase-installations
  • Component version: firebase-analytics:17.4.3, firebase-messaging:20.2.1, firebase-config:19.1.4, firebase-crashlytics:17.1.0 -> firebase-installations:16.3.2

Description

Crashlytics reported some crashes on some OnePlus 6 devices with Android 10 on 19/07/2020.

Stacktrace

Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.length()' on a null object reference
       at com.google.firebase.installations.FirebaseInstallations.registerFidWithServer(FirebaseInstallations.java:452)
       at com.google.firebase.installations.FirebaseInstallations.doNetworkCallIfNecessary(FirebaseInstallations.java:331)
       at com.google.firebase.installations.FirebaseInstallations.lambda$doGetId$1(FirebaseInstallations.java:296)
       at com.google.firebase.installations.FirebaseInstallations$$Lambda$3.run(FirebaseInstallations.java:2000)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
       at java.lang.Thread.run(Thread.java:919)
@google-oss-bot
Copy link
Contributor

I found a few problems with this issue:

  • I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
  • This issue does not seem to follow the issue template. Make sure you provide all the required information.

@rlazo rlazo added firebase-installations Firebase Installations service and removed needs-triage labels Jul 20, 2020
@rlazo
Copy link
Collaborator

rlazo commented Jul 20, 2020

Hi @francescocervone this issue was addressed in #1714 but we haven't made a release including with the fix yet. I'll keep this issue updated when the fix is out in a release.

@rayliverified
Copy link

Is this caused by clearing SharedPreferences?

    val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
    sharedPreferences.edit().clear().commit()

After clearing SharedPreferences, this crash might happen.

@nedols
Copy link

nedols commented Jul 27, 2020

Same issue.

Below dependencies used in my project.

def firebase_messagging = "20.2.3"
implementation "com.google.firebase:firebase-messaging:$firebase_messagging"

def firebase_config = "19.2.0"
implementation ("com.google.firebase:firebase-config:$firebase_config", {
        exclude group: 'com.google.protobuf'
}) // fixme: see issue still present at https://github.com/firebase/firebase-android-sdk/issues/1143

def firebase_auth = "19.3.2"
implementation "com.google.firebase:firebase-auth-ktx:$firebase_auth"

def realtime_database = "19.3.1"
implementation "com.google.firebase:firebase-database:$realtime_database"

def firebase_functions = "19.0.2"
implementation "com.google.firebase:firebase-functions-ktx:$firebase_functions"

def firestore_ktx = "21.1.1"
implementation "com.google.firebase:firebase-firestore-ktx:$firestore_ktx"

def firebase_analytics = "17.4.4"
implementation "com.google.firebase:firebase-analytics-ktx:$firebase_analytics"

def firebase_crashlytics = "17.1.1"
implementation "com.google.firebase:firebase-crashlytics:$firebase_crashlytics"

def firebase_appindexing = "19.1.0"
implementation "com.google.firebase:firebase-appindexing:$firebase_appindexing"

and stacktrace:

FATAL EXCEPTION: firebase-installations-executor-1
    Process: <my package id>, PID: 1690
    java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.length()' on a null object reference
        at com.google.firebase.installations.FirebaseInstallations.registerFidWithServer(FirebaseInstallations.java:452)
        at com.google.firebase.installations.FirebaseInstallations.doNetworkCallIfNecessary(FirebaseInstallations.java:331)
        at com.google.firebase.installations.FirebaseInstallations.lambda$doGetId$1(FirebaseInstallations.java:296)
        at com.google.firebase.installations.FirebaseInstallations$$Lambda$3.run(Unknown Source:2)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:764)

@wugeo0824
Copy link

Anything we can do to temporarily stop this crash from happening?

@ankitaj224
Copy link
Contributor

@searchy2 That's highly likely. Do you or others who are reporting crash clear the shared prefs?

@wugeo0824 We are rolling out a fix this week which should be released either by Friday or Monday next week. Updating to the latest version of FCM releasing this week should fix the issue.

@StainlessStlRat
Copy link

StainlessStlRat commented Jul 29, 2020

Is this caused by clearing SharedPreferences?

    val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
    sharedPreferences.edit().clear().commit()

After clearing SharedPreferences, this crash might happen.

This crash did start popping up for me after I renamed a shared preference's key value.

@rvijayraghavan
Copy link

@ankitaj224 We are noticing this issue on a new app install. Looking forward to the library update with the fix.

@lucas34
Copy link

lucas34 commented Aug 3, 2020

Is this issue fixed ? It's mentioned in the latest release note but the ticket is still open
https://firebase.google.com/support/release-notes/android#installations_v16-3-2

@calvarez-ov
Copy link

We have version 16.3.2, and we have this crash. So it's weird that it's mentioned as a fix in 16.3.2. Note that 16.3.2 is also the version mentioned in the description of this ticket.

@lucas34
Copy link

lucas34 commented Aug 3, 2020

Looks like a typo in the release note. 16.3.2 was rollout awhile ago. I'm trying to update to 16.3.3 to see if it fix.

@ankitaj224
Copy link
Contributor

@lucas34 You are right, that's a typo. Thanks for catching it, we will fix the release notes in a short while. firebase-installations:16.3.3 or firebase-messaging:20.2.4 contain the probable fix.

@ankitaj224
Copy link
Contributor

Please let us know if anyone has tried out the fix.

@menting311
Copy link

@ankitaj224 - I am confused..the current version of crashlytics is firebase-crashlytics:17.1.1. How do we use firebase-installations if we are using the crashlytics SDK?

@ankitaj224
Copy link
Contributor

@menting311 Thanks for reaching out & sorry for the confusion. You have two options:

  1. Add a direct dependency on firebase-installations:16.3.3 in your app.
  2. Or await for Crashlytics new release which is planned for this week ( ~ Aug 13th).

@lucas34
Copy link

lucas34 commented Aug 13, 2020

We updated to 16.3.3 and it solved the issue. Thanks !

@ankitaj224
Copy link
Contributor

@lucas34 Thank you so much for confirming.

I will go ahead and close this issue. Please feel free to reach out if you continue to see this issue.

@menting311
Copy link

@ankitaj224 - So is this fix in crashlytics 17.2.1? I was looking at the release notes on this and I am not seeing anything referring to this?

https://firebase.google.com/support/release-notes/android#crashlytics_v17-2-1

@ankitaj224
Copy link
Contributor

@menting311 Yes, crashlytics 17.2.1 transitively get this fix as it depends on firebase-installations:16.3.3. https://firebase.google.com/support/release-notes/android#installations_v16-3-3

@MahdiYusefi
Copy link

it's been two days that this crash happens in crashlytics:17.1.1 only for android 4 meanwhile versions that contains 17.1.1 its been live from about one week ago.

@ankitaj224
Copy link
Contributor

@MahdiYusefi Its possible probably some disk write issue. I would recommend updating to crashlytics 17.2.1 and that should fix the issue.

Thanks.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
firebase-installations Firebase Installations service needs-info
Projects
None yet
Development

No branches or pull requests