'java.lang.String.toLowerCase()' 'com.google.android.gms.internal.zzbsp.zzabx' class 中的 crashlytics 报告中的空对象引用

Getting 'java.lang.String.toLowerCase()' on a null object reference' in crashlytics report in 'com.google.android.gms.internal.zzbsp.zzabx' class

我有一个应用程序,我在其中集成了 Crashlystics 库,它可以捕获应用程序中的致命问题并向开发人员报告。

方法如下:

public class MyApplication extends Application {

    @Override
    public void onCreate() {
        super.onCreate();
        Fabric.with(this, new Crashlytics());
    }
}

依赖项如下:

apply plugin: 'io.fabric'
compile('com.crashlytics.sdk.android:crashlytics:2.6.6@aar') {
        transitive = true;
}
compile 'com.google.android.gms:play-services:10.2.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 in com.google.android.gms.internal.zzbsp.zzabx (Unknown Source) class。此错误发生在 LGE 设备 运行 android 棉花糖上。

来自 Fabric.io 的 crashlytics 的完整堆栈跟踪:

#0. Crashed: TubeSockReader-1: 0 0 0x0000000000000000
       at com.google.android.gms.internal.zzbsp.zzabx(Unknown Source)
       at com.google.android.gms.internal.zzbsm.zzabv(Unknown Source)
       at com.google.android.gms.internal.zzbsm.getThreadFactory(Unknown Source)
       at com.google.android.gms.internal.zzbsm.run(Unknown Source)
       at java.lang.Thread.run(Thread.java:818)

--

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.android.gms.internal.zzbsp.zzabx(Unknown Source)
       at com.google.android.gms.internal.zzbsm.zzabv(Unknown Source)
       at com.google.android.gms.internal.zzbsm.getThreadFactory(Unknown Source)
       at com.google.android.gms.internal.zzbsm.run(Unknown Source)
       at java.lang.Thread.run(Thread.java:818)

#0. Crashed: TubeSockReader-1: 0 0 0x0000000000000000
       at com.google.android.gms.internal.zzbsp.zzabx(Unknown Source)
       at com.google.android.gms.internal.zzbsm.zzabv(Unknown Source)
       at com.google.android.gms.internal.zzbsm.getThreadFactory(Unknown Source)
       at com.google.android.gms.internal.zzbsm.run(Unknown Source)
       at java.lang.Thread.run(Thread.java:818)

#1. HeapTaskDaemon
       at dalvik.system.VMRuntime.runHeapTasks(VMRuntime.java)
       at java.lang.Daemons$HeapTaskDaemon.run(Daemons.java:355)
       at java.lang.Thread.run(Thread.java:818)

#2. pool-6-thread-1
       at java.lang.Object.wait(Object.java)
       at java.lang.Thread.parkFor$(Thread.java:1220)
       at sun.misc.Unsafe.park(Unsafe.java:299)
       at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:198)
       at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2053)
       at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1090)
       at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1071)
       at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1038)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1098)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
       at java.lang.Thread.run(Thread.java:818)

#3. OkHttp ConnectionPool
       at java.lang.Object.wait(Object.java)
       at com.android.okhttp.ConnectionPool.performCleanup(ConnectionPool.java:305)
       at com.android.okhttp.ConnectionPool.runCleanupUntilPoolIsEmpty(ConnectionPool.java:242)
       at com.android.okhttp.ConnectionPool.-wrap0(ConnectionPool.java)
       at com.android.okhttp.ConnectionPool.run(ConnectionPool.java:97)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
       at java.lang.Thread.run(Thread.java:818)

#4. TubeSockReader-1
       at java.lang.Object.wait(Object.java)
       at java.lang.Thread.parkFor$(Thread.java:1220)
       at sun.misc.Unsafe.park(Unsafe.java:299)
       at java.util.concurrent.locks.LockSupport.park(LockSupport.java:158)
       at java.util.concurrent.FutureTask.awaitDone(FutureTask.java:421)
       at java.util.concurrent.FutureTask.get(FutureTask.java:163)
       at com.crashlytics.android.core.CrashlyticsBackgroundWorker.submitAndWait(SourceFile:43)
       at com.crashlytics.android.core.CrashlyticsController.handleUncaughtException(SourceFile:278)
       at com.crashlytics.android.core.CrashlyticsController.onUncaughtException(SourceFile:262)
       at com.crashlytics.android.core.CrashlyticsUncaughtExceptionHandler.uncaughtException(SourceFile:30)
       at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:693)
       at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:690)

#5. GAC_Executor[1]
       at java.lang.Object.wait(Object.java)
       at java.lang.Thread.parkFor$(Thread.java:1220)
       at sun.misc.Unsafe.park(Unsafe.java:299)
       at java.util.concurrent.locks.LockSupport.park(LockSupport.java:158)
       at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2013)
       at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:410)
       at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1038)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1098)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
       at com.google.android.gms.internal.zzadd.run(Unknown Source)
       at java.lang.Thread.run(Thread.java:818)

#6. Queue
       at java.lang.Object.wait(Object.java)
       at java.lang.Thread.parkFor$(Thread.java:1220)
       at sun.misc.Unsafe.park(Unsafe.java:299)
       at java.util.concurrent.locks.LockSupport.park(LockSupport.java:158)
       at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2013)
       at java.util.concurrent.PriorityBlockingQueue.take(PriorityBlockingQueue.java:510)
       at io.fabric.sdk.android.services.concurrency.DependencyPriorityBlockingQueue.performOperation(SourceFile:197)
       at io.fabric.sdk.android.services.concurrency.DependencyPriorityBlockingQueue.get(SourceFile:236)
       at io.fabric.sdk.android.services.concurrency.DependencyPriorityBlockingQueue.take(SourceFile:65)
       at io.fabric.sdk.android.services.concurrency.DependencyPriorityBlockingQueue.take(SourceFile:46)
       at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1038)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1098)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
       at java.lang.Thread.run(Thread.java:818)

#7. Answers Events Handler1
       at java.lang.Object.wait(Object.java)
       at java.lang.Thread.parkFor$(Thread.java:1220)
       at sun.misc.Unsafe.park(Unsafe.java:299)
       at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:198)
       at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2053)
       at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1090)
       at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1071)
       at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1038)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1098)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
       at io.fabric.sdk.android.services.common.ExecutorUtils.onRun(SourceFile:75)
       at io.fabric.sdk.android.services.common.BackgroundPriorityRunnable.run(SourceFile:30)
       at java.lang.Thread.run(Thread.java:818)

#8. GoogleApiHandler
       at android.os.MessageQueue.nativePollOnce(MessageQueue.java)
       at android.os.MessageQueue.next(MessageQueue.java:323)
       at android.os.Looper.loop(Looper.java:135)
       at android.os.HandlerThread.run(HandlerThread.java:61)

#9. main
       at java.lang.Character.isDigit(Character.java:2672)
       at java.lang.Character.isDigit(Character.java:2658)
       at java.util.Formatter$FormatSpecifierParser.nextInt(Formatter.java:2406)
       at java.util.Formatter$FormatSpecifierParser.parseArgumentIndexAndFlags(Formatter.java:2329)
       at java.util.Formatter$FormatSpecifierParser.parseFormatToken(Formatter.java:2298)
       at java.util.Formatter.doFormat(Formatter.java:1071)
       at java.util.Formatter.format(Formatter.java:1042)
       at java.util.Formatter.format(Formatter.java:1011)
       at java.lang.String.format(String.java:1554)
       at java.lang.String.format(String.java:1528)
       at com.getsportalapp.sportal.SignUpActivity.run(SourceFile:599)
       at android.os.Handler.handleCallback(Handler.java:739)
       at android.os.Handler.dispatchMessage(Handler.java:95)
       at android.os.Looper.loop(Looper.java:148)
       at android.app.ActivityThread.main(ActivityThread.java:5421)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

#10. AsyncTask #2
       at java.lang.Object.wait(Object.java)
       at java.lang.Thread.parkFor$(Thread.java:1220)
       at sun.misc.Unsafe.park(Unsafe.java:299)
       at java.util.concurrent.locks.LockSupport.park(LockSupport.java:158)
       at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2013)
       at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:410)
       at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1038)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1098)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
       at java.lang.Thread.run(Thread.java:818)

#11. FinalizerWatchdogDaemon
       at java.lang.Thread.sleep(Thread.java)
       at java.lang.Thread.sleep(Thread.java:1031)
       at java.lang.Thread.sleep(Thread.java:985)
       at java.lang.Daemons$FinalizerWatchdogDaemon.sleepFor(Daemons.java:273)
       at java.lang.Daemons$FinalizerWatchdogDaemon.waitForFinalization(Daemons.java:284)
       at java.lang.Daemons$FinalizerWatchdogDaemon.run(Daemons.java:232)
       at java.lang.Thread.run(Thread.java:818)

#12. GAC_Executor[0]
       at java.lang.Object.wait(Object.java)
       at java.lang.Thread.parkFor$(Thread.java:1220)
       at sun.misc.Unsafe.park(Unsafe.java:299)
       at java.util.concurrent.locks.LockSupport.park(LockSupport.java:158)
       at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2013)
       at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:410)
       at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1038)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1098)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
       at com.google.android.gms.internal.zzadd.run(Unknown Source)
       at java.lang.Thread.run(Thread.java:818)

#13. AsyncTask #1
       at java.lang.Object.wait(Object.java)
       at java.lang.Thread.parkFor$(Thread.java:1220)
       at sun.misc.Unsafe.park(Unsafe.java:299)
       at java.util.concurrent.locks.LockSupport.park(LockSupport.java:158)
       at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2013)
       at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:410)
       at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1038)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1098)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
       at java.lang.Thread.run(Thread.java:818)

#14. pool-1-thread-1
       at java.lang.Object.wait(Object.java)
       at java.lang.Thread.parkFor$(Thread.java:1220)
       at sun.misc.Unsafe.park(Unsafe.java:299)
       at java.util.concurrent.locks.LockSupport.park(LockSupport.java:158)
       at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2013)
       at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:410)
       at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1038)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1098)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
       at java.lang.Thread.run(Thread.java:818)

#15. pool-2-thread-1
       at java.lang.Object.wait(Object.java)
       at java.lang.Thread.parkFor$(Thread.java:1220)
       at sun.misc.Unsafe.park(Unsafe.java:299)
       at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:198)
       at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2053)
       at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1090)
       at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1071)
       at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1038)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1098)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
       at java.lang.Thread.run(Thread.java:818)

#16. FirebaseDatabaseWorker
       at java.lang.Object.wait(Object.java)
       at java.lang.Thread.parkFor$(Thread.java:1220)
       at sun.misc.Unsafe.park(Unsafe.java:299)
       at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:198)
       at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2053)
       at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1090)
       at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1071)
       at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1038)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1098)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
       at java.lang.Thread.run(Thread.java:818)

#17. pool-3-thread-1
       at java.lang.Object.wait(Object.java)
       at java.lang.Thread.parkFor$(Thread.java:1220)
       at sun.misc.Unsafe.park(Unsafe.java:299)
       at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:198)
       at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2053)
       at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1090)
       at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1071)
       at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1038)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1098)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
       at java.lang.Thread.run(Thread.java:818)

#18. Measurement Worker
       at java.lang.Object.wait(Object.java)
       at java.lang.Object.wait(Object.java:423)
       at com.google.android.gms.internal.zzaud$zzd.run(Unknown Source)

#19. Queue
       at java.lang.Object.wait(Object.java)
       at java.lang.Thread.parkFor$(Thread.java:1220)
       at sun.misc.Unsafe.park(Unsafe.java:299)
       at java.util.concurrent.locks.LockSupport.park(LockSupport.java:158)
       at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2013)
       at java.util.concurrent.PriorityBlockingQueue.take(PriorityBlockingQueue.java:510)
       at io.fabric.sdk.android.services.concurrency.DependencyPriorityBlockingQueue.performOperation(SourceFile:197)
       at io.fabric.sdk.android.services.concurrency.DependencyPriorityBlockingQueue.get(SourceFile:236)
       at io.fabric.sdk.android.services.concurrency.DependencyPriorityBlockingQueue.take(SourceFile:65)
       at io.fabric.sdk.android.services.concurrency.DependencyPriorityBlockingQueue.take(SourceFile:46)
       at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1038)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1098)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
       at java.lang.Thread.run(Thread.java:818)

#20. FinalizerDaemon
       at java.lang.Object.wait(Object.java)
       at java.lang.Object.wait(Object.java:423)
       at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:101)
       at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:72)
       at java.lang.Daemons$FinalizerDaemon.run(Daemons.java:185)
       at java.lang.Thread.run(Thread.java:818)

#21. ReferenceQueueDaemon
       at java.lang.Object.wait(Object.java)
       at java.lang.Daemons$ReferenceQueueDaemon.run(Daemons.java:147)
       at java.lang.Thread.run(Thread.java:818)

#22. Crashlytics Exception Handler1
       at dalvik.system.VMStack.getThreadStackTrace(VMStack.java)
       at java.lang.Thread.getStackTrace(Thread.java:580)
       at java.lang.Thread.getAllStackTraces(Thread.java:522)
       at com.crashlytics.android.core.CrashlyticsController.writeSessionEvent(SourceFile:1092)
       at com.crashlytics.android.core.CrashlyticsController.writeFatal(SourceFile:831)
       at com.crashlytics.android.core.CrashlyticsController.access0(SourceFile:59)
       at com.crashlytics.android.core.CrashlyticsController.call(SourceFile:285)
       at com.crashlytics.android.core.CrashlyticsController.call(SourceFile:278)
       at java.util.concurrent.FutureTask.run(FutureTask.java:237)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
       at io.fabric.sdk.android.services.common.ExecutorUtils.onRun(SourceFile:75)
       at io.fabric.sdk.android.services.common.BackgroundPriorityRunnable.run(SourceFile:30)
       at java.lang.Thread.run(Thread.java:818)

这是什么错误,我为什么会收到它?

首先,您发布了一个线程转储,这只是略有帮助,而诊断问题真正需要的是来自异常的完整堆栈跟踪。

也就是说,在线程转储中出现的唯一 Activity 是 SignUpActivity,所以我建议去那里看看。

错误实际上是由于尝试对空字符串引用调用 toLowerCase。例如,如果您使用 AsyncTask 并从后台线程访问文本字段,但 Activity 已被破坏(例如设备旋转),则可能会发生这种情况。

关于 'com.google.android.gms.internal.zzbsp.zzabx' 的一点很可能是转移注意力,崩溃报告库的副作用。 先看看自己的代码。

此外,如前所述,实际的堆栈跟踪(如果可用)可能会非常有用。

这是 GMS 库中的错误。 Google 的一些虚拟测试设备上出现此错误(总是 Nexus 5x API 23 en-US ...)

查看此问题以获取更多信息:

问题是:https://issuetracker.google.com/issues/37135148