问题描述
我在应用启动时就将NPE用于生产环境,并且仅在使用adb重新安装后才得到一次.
I am getting NPE in production build on app start and only once after reinstalling with adb.
Caused by java.lang.NullPointerException
Attempt to invoke interface method 'void com.google.firebase.database.obfuscated.f.a(java.lang.Runnable)' on a null object reference
com.google.firebase.database.obfuscated.zzab.zza (SourceFile:276)
com.google.firebase.database.obfuscated.zzab. (SourceFile:90)
com.google.firebase.database.obfuscated.zzad.zzb (SourceFile:101)
com.google.firebase.database.obfuscated.zzad.zza (SourceFile:42)
com.google.firebase.database.FirebaseDatabase.zza (SourceFile:357)
com.google.firebase.database.FirebaseDatabase.getReference(SourceFile:201)
我想无论将什么引用传递给getReference()方法,我都不应获取NPE-尽管我传递的是正确的引用.
I suppose I should not get NPE no matter what reference I am passing to getReference() method - although I am passing correct one.
以下Firebase版本似乎会发生这种情况:
This seems to happen with following firebase versions:
firebase_core_version = "16.0.3"
firebase_auth_version = "16.0.3"
firebase_database_version = "16.0.2"
我无法使用以下方式复制它:
I am unable to reproduce it using:
firebase_core_version = "16.0.0"
firebase_auth_version = "16.0.1"
firebase_database_version = "16.0.1"
推荐答案
将其添加到ProGuard配置中,以便从混淆中排除这些类:
add this to the ProGuard configuration, in order to exclude these classes from obfuscation:
-keep,includedescriptorclasses class com.google.firebase.** { *; }
事实上,只有发行版本受到影响的提示-
the fact, that only the release build is being affected hints for this -
不同的库版本可能提供不同的(库)使用者规则.
different library versions may provide different (library) consumer rules.
这篇关于在FirebaseDatabase.getReference()中获取NPE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!