NullPointer on toLowerCase but I don't use that method anywhere

AndroidFirebaseNullpointerexceptionGoogle Play-Services

Android Problem Overview


I'm getting the following crash dump in Firebase Crash Reports:

Exception java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.String.toLowerCase(java.util.Locale)' on a null object reference
bnp.run (bnp.java:56)
java.lang.Thread.run (Thread.java:818)

The problem is that I don't use the String.toLowerCase() method anywhere in the project. In Android Studio, I did Edit->Find In Path for the method and got no results, however, it does appear 100+ times if I search in the libraries. But I cannot find the "bnp.java" anywhere.

Thanks for your help!

Edit: A previous crash report was not proguard-affected and revealed it may be due to google-play-services or Firebase. I only use gms:play-services-places and gms:play-services-auth in my app, along with many Firebase dependencies.

Exception java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.String.toLowerCase(java.util.Locale)' on a null object reference
bnp.run (:com.google.android.gms.DynamiteModulesC:56)
java.lang.Thread.run (Thread.java:818)

Android Solutions


Solution 1 - Android

I can't comment yet, so I will post this as a possible solution, but this seems like an error on Google's side. Multiple people are reporting this crash on the exact same device with the exact same region. So it seems Google runs your app on a virtual or automated device and then that device crashes. This device seems to be a Nexus 5x with local us-US and API level 23.

Source: https://code.google.com/p/android/issues/detail?id=233549

Solution 2 - Android

I got this error when my code was trying to create a connection to certain amqp service using an invalid URL. Once I modified it to the proper value, the exception is gone. So check your code.

Solution 3 - Android

My app ran into a similar issue.

When launched in Stock android devices(Mi A1), the App crashed with " keeps stopping popup". The Crashlytics in Fabric reported it as the

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 bfx.run(:com.google.android.gms.dynamite_dynamitemodulesc@13452060@13.4.52 (040708-202483333):80)
   at java.lang.Thread.run(Thread.java:818)

But when I checked the Pre-launch report of the Release management in Google Play Console, it showed that the app was crashing for Pixel & Pixel 2 for an entirely different reason. The issue shown was

FATAL EXCEPTION: main Process: in.quickall.quickall, PID: 8345
java.lang.RuntimeException: Unable to start activity ComponentInfo{in.quickall.quickall/in.quickall.quickall.Main.MainActivity}: android.content.res.Resources$NotFoundException: Drawable in.quickall.quickall:drawable/splash_screen with resource ID #0x7f0700c0
	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2817)
	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
	at android.app.ActivityThread.-wrap11(Unknown Source:0)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
	at android.os.Handler.dispatchMessage(Handler.java:105)
	at android.os.Looper.loop(Looper.java:164)
	at android.app.ActivityThread.main(ActivityThread.java:6541)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
    

And the issue started from the APK version were I implemented the code (given below) to remove the white screen on launch.

<style name="SplashTheme" parent="AppTheme">
    <item name="android:windowBackground">@drawable/splash_screen</item>
</style>

I removed this piece of code and now the Pre-launch report shows it as working fine in the Pixel devices.

Now the app launches correctly, but has to have the white screen at launch.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionPeter KeefeView Question on Stackoverflow
Solution 1 - AndroidTeun VosView Answer on Stackoverflow
Solution 2 - AndroidZvonkoView Answer on Stackoverflow
Solution 3 - AndroidAswindev AView Answer on Stackoverflow