Firebase-android-sdk: NullPointerException on Database

Created on 23 Dec 2018  路  11Comments  路  Source: firebase/firebase-android-sdk

Environment

  • Android Studio version: 3.2.1
  • Firebase Component: Database
  • Component version: 16.0.5

Steps to reproduce:

I got this crash report on Crashlytics. The device is a Nexus 5X, Android version 6.0.1.

Relevant Code:

Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.String.toLowerCase(java.util.Locale)' on a null object reference
       at com.google.firebase.database.tubesock.WebSocketHandshake.verifyServerHandshakeHeaders(com.google.firebase:firebase-database@@16.0.5:111)
       at com.google.firebase.database.tubesock.WebSocket.runReader(com.google.firebase:firebase-database@@16.0.5:418)
       at com.google.firebase.database.tubesock.WebSocket.access$000(com.google.firebase:firebase-database@@16.0.5:47)
       at com.google.firebase.database.tubesock.WebSocket$2.run(com.google.firebase:firebase-database@@16.0.5:143)
       at java.lang.Thread.run(Thread.java:818)

Most helpful comment

Per the referenced PR, the fix should go out in the next SDK release, currently scheduled for end of January.

All 11 comments

Same here

Me too.
There is a pull request addressing this issue
https://github.com/firebase/firebase-android-sdk/pull/119

Same here.

The same here. The same device and Android version.

Per the referenced PR, the fix should go out in the next SDK release, currently scheduled for end of January.

Same here with latest C++ SDK 5.5.0

Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.String.toLowerCase(java.util.Locale)' on a null object reference
at com.google.firebase.database.tubesock.WebSocketHandshake.verifyServerHandshakeHeaders(com.google.firebase:firebase-database@@16.0.5:111)
at com.google.firebase.database.tubesock.WebSocket.runReader(com.google.firebase:firebase-database@@16.0.5:418)
at com.google.firebase.database.tubesock.WebSocket.access$000(com.google.firebase:firebase-database@@16.0.5:47)
at com.google.firebase.database.tubesock.WebSocket$2.run(com.google.firebase:firebase-database@@16.0.5:143)
at java.lang.Thread.run(Thread.java:818)

Hi @mrpuzzler,

From your stack trace, it looks like you're using version 16.0.5 of the Database. This NPE issue was fixed in 16.0.6 (released on 2019-01-25). https://firebase.google.com/support/release-notes/android. Could you update the Database component and try again?

I use version as declared here https://firebase.google.com/docs/cpp/setup ... is it safe to use other version?

Yes, it should be safe; the docs just need to be updated. (I'll see if I can get that to happen.)

Ok; slight refinement/correction to my last comment:

If you've got a c++ app, then it should be safe to update to 16.0.6 within your gradle file as I suggested.

If you've got a unity app, then it's slightly more involved:

  • Edit Assets/Firebase/Editor/DatabaseDependencies.xml in your project, to update RTDB Android to 16.0.6
  • Then, 'Force Resolve' in the 'Android Resolver' menu.

The docs themselves represent the versions that were in use when the sdk's were spun up, so they're the "best" versions to use, but in cases like this where there's a known bug that's been fixed, it should be safe to upgrade beyond the versions listed so long as there's no breaking changes. (Breaking changes are indicated by an increase in the major version number.)

I use C++ app, updated to 16.0.6 ... uploaded/released app ... hope it will fly without any bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

miraculix-druids picture miraculix-druids  路  3Comments

mrsylerpowers picture mrsylerpowers  路  3Comments

ANR
RodolfoGS picture RodolfoGS  路  4Comments

gwoodhouse picture gwoodhouse  路  4Comments

jkasten2 picture jkasten2  路  4Comments