空对象引用上的com.google.android.gms.internal.firebase-perf.zzq.zzb(boolean)'

时间:2018-05-22 04:07:39

标签: android firebase

环境

  • Android设备:MI 5\ MI 6
  • Android操作系统版本:8.0.0
  • Google Play服务版:不使用谷歌服务
  • Firebase / Play Services SDK版本:com.google.firebase:firebase-plugins:1.1.0com.google.firebase:firebase-perf:15.1.0
  • TargetSdkVersion:26

问题

java.lang.NullPointerException

Attempt to invoke virtual method 'void     com.google.android.gms.internal.firebase-perf.zzq.zzb(boolean)' on a null object reference
com.google.android.gms.internal.firebase-perf.zzg.zzc(Unknown Source:2)
com.google.android.gms.internal.firebase-perf.zzk.run(Unknown Source:4)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
java.lang.Thread.run(Thread.java:764)

logcat的

FirebaseApp: Firebase API initialization failure.
java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invoke(Native Method)
    at com.google.firebase.FirebaseApp.zza(Unknown Source:72)
    at com.google.firebase.FirebaseApp.zzc(Unknown Source:49)
    at com.google.firebase.FirebaseApp.initializeApp(Unknown Source:119)
    at com.google.firebase.FirebaseApp.initializeApp(Unknown Source:2)
    at com.google.firebase.FirebaseApp.initializeApp(Unknown Source:28)
    at com.google.firebase.provider.FirebaseInitProvider.onCreate(Unknown Source:4)
    at android.content.ContentProvider.attachInfo(ContentProvider.java:1927)
    at android.content.ContentProvider.attachInfo(ContentProvider.java:1902)
    at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source:23)
    at android.app.ActivityThread.installProvider(ActivityThread.java:6425)
    at android.app.ActivityThread.installContentProviders(ActivityThread.java:5939)
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5851)
    at android.app.ActivityThread.-wrap1(Unknown Source:0)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1689)
    at android.os.Handler.dispatchMessage(Handler.java:105)
    at android.os.Looper.loop(Looper.java:164)
    at android.app.ActivityThread.main(ActivityThread.java:6683)
    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:782)
 Caused by: java.lang.SecurityException: Failed to find provider com.google.android.gms.phenotype for user 0; expected to find a valid ContentProvider for this authority
    at android.os.Parcel.readException(Parcel.java:1942)
    at android.os.Parcel.readException(Parcel.java:1888)
    at android.content.IContentService$Stub$Proxy.registerContentObserver(IContentService.java:768)
    at android.content.ContentResolver.registerContentObserver(ContentResolver.java:1940)
    at android.content.ContentResolver.registerContentObserver(ContentResolver.java:1929)
    at com.google.android.gms.internal.measurement.zzwp.zza(Unknown Source:32)
    at com.google.android.gms.internal.measurement.zzws.zzry(Unknown Source:33)
    at com.google.android.gms.internal.measurement.zzws.get(Unknown Source:14)
    at com.google.android.gms.internal.measurement.zzex.get(Unknown Source:2)
    at com.google.android.gms.internal.measurement.zzfg.zziu(Unknown Source:7)
    at com.google.android.gms.internal.measurement.zzfg.isLoggable(Unknown Source:0)
    at com.google.android.gms.internal.measurement.zzfg.zza(Unknown Source:3)
    at com.google.android.gms.internal.measurement.zzfi.log(Unknown Source:12)
    at com.google.android.gms.internal.measurement.zzgl.<init>(Unknown Source:226)
    at com.google.android.gms.internal.measurement.zzgl.zzg(Unknown Source:28)
    at com.google.android.gms.measurement.AppMeasurement.getInstance(Unknown Source:0)
    at java.lang.reflect.Method.invoke(Native Method) 
    at com.google.firebase.FirebaseApp.zza(Unknown Source:72) 
    at com.google.firebase.FirebaseApp.zzc(Unknown Source:49) 
    at com.google.firebase.FirebaseApp.initializeApp(Unknown Source:119) 
    at com.google.firebase.FirebaseApp.initializeApp(Unknown Source:2) 
    at com.google.firebase.FirebaseApp.initializeApp(Unknown Source:28) 
    at com.google.firebase.provider.FirebaseInitProvider.onCreate(Unknown Source:4) 
    at android.content.ContentProvider.attachInfo(ContentProvider.java:1927) 
    at android.content.ContentProvider.attachInfo(ContentProvider.java:1902) 
    at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source:23) 
    at android.app.ActivityThread.installProvider(ActivityThread.java:6425) 
    at android.app.ActivityThread.installContentProviders(ActivityThread.java:5939) 
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5851) 
    at android.app.ActivityThread.-wrap1(Unknown Source:0) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1689) 
    at android.os.Handler.dispatchMessage(Handler.java:105) 
    at android.os.Looper.loop(Looper.java:164) 
    at android.app.ActivityThread.main(ActivityThread.java:6683) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) 



    java.lang.SecurityException: Failed to find provider com.google.android.gsf.gservices for user 0; expected to find a valid ContentProvider for this authority
    at android.os.Parcel.readException(Parcel.java:1942)
    at android.os.Parcel.readException(Parcel.java:1888)
    at android.content.IContentService$Stub$Proxy.registerContentObserver(IContentService.java:768)
    at android.content.ContentResolver.registerContentObserver(ContentResolver.java:1940)
    at android.content.ContentResolver.registerContentObserver(ContentResolver.java:1929)
    at com.google.android.gms.internal.firebase-perf.zza.zza(Unknown Source:38)
    at com.google.android.gms.internal.firebase-perf.zzq.<init>(Unknown Source:145)
    at com.google.android.gms.internal.firebase-perf.zzg.zzp(Unknown Source:127)
    at com.google.android.gms.internal.firebase-perf.zzg.zzb(Unknown Source:0)
    at com.google.android.gms.internal.firebase-perf.zzh.run(Unknown Source:2)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
    at java.lang.Thread.run(Thread.java:764)


    java.lang.NullPointerException: Attempt to invoke virtual method 'void com.google.android.gms.internal.firebase-perf.zzq.zzb(boolean)' on a null object reference
    at com.google.android.gms.internal.firebase-perf.zzg.zzc(Unknown Source:2)
    at com.google.android.gms.internal.firebase-perf.zzk.run(Unknown Source:4)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
    at java.lang.Thread.run(Thread.java:764)

看起来SecurityException会导致Firebase API initialization failure,然后会出现一些NullPointerExceptions。

我试图降级Performance Tools,这没用。 然后我将TargetSdkVersion从26设置为23,问题解除了。

2 个答案:

答案 0 :(得分:0)

将此添加到应用级别中的底部apply plugin: 'com.google.gms.google-services'&#39; 并使用this最新的firebase依赖项,如果您使用的是android studio 3.x版本,请使用'com.google.firebase:firebase-plugins:1.1.5'

答案 1 :(得分:0)

The documentation表示Firebase效果监控取决于Google Play服务:

  

在开始之前,您需要在您的环境中设置一些内容:

     
      
  • 运行Android 4.0(Ice Cream Sandwich)或更新版本的设备,以及 Google Play服务15.2.0或更高版本
  •   
  • 来自Google Repository的Google Play服务SDK,可在Android SDK Manager中找到
  •   
  • 最新版本的Android Studio 2.2或更高版本
  •