免安装应用程序在 adview.loadAd 上崩溃,SecurityException:找不到提供商 com.google.android.gsf.gservices

Instant app crashing on adview.loadAd, SecurityException: Failed to find provider com.google.android.gsf.gservices

我使用的是 play services ads 10.2.6,它与安装的应用程序配合得很好。

这是堆栈跟踪:

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.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)
     Caused by: 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:1948)
        at android.os.Parcel.readException(Parcel.java:1894)
        at android.content.IContentService$Stub$Proxy.registerContentObserver(IContentService.java:768)
        at android.content.ContentResolver.registerContentObserver(ContentResolver.java:1924)
        at android.content.ContentResolver.registerContentObserver(ContentResolver.java:1913)
        at zh.a(:com.google.android.gms.DynamiteModulesA:7)
        at zh.a(:com.google.android.gms.DynamiteModulesA:84)
        at jg.<init>(:com.google.android.gms.DynamiteModulesA:14)
        at jf.<init>(:com.google.android.gms.DynamiteModulesA:1)
        at com.google.android.gms.ads.clearcut.a.<init>(:com.google.android.gms.DynamiteModulesA:6)
        at com.google.android.gms.ads.internal.ag.a(:com.google.android.gms.DynamiteModulesA:1)
        at com.google.android.gms.ads.ChimeraAdManagerCreatorImpl.newAdManagerByType(:com.google.android.gms.DynamiteModulesA:17)
        at com.google.android.gms.ads.internal.client.an.onTransact(:com.google.android.gms.DynamiteModulesA:63)
        at android.os.Binder.transact(Binder.java:604)
        at com.google.android.gms.ads.internal.client.ak.newAdManagerByType(:com.google.android.gms:3)
        at com.google.android.gms.ads.AdManagerCreatorImpl.newAdManagerByType(:com.google.android.gms:12)
        at com.google.android.gms.ads.internal.client.aj.onTransact(:com.google.android.gms:32)
        at android.os.Binder.transact(Binder.java:604)
        at com.google.android.gms.internal.zzeu$zza$zza.zza(Unknown Source:56)
        at com.google.android.gms.internal.zzeb.zza(Unknown Source:17)
        at com.google.android.gms.internal.zzek.zzeI(Unknown Source:15)
        at com.google.android.gms.internal.zzek.zzeJ(Unknown Source:0)
        at com.google.android.gms.internal.zzek$zza.zzeR(Unknown Source:0)
        at com.google.android.gms.internal.zzek.zza(Unknown Source:32)
        at com.google.android.gms.internal.zzek.zza(Unknown Source:11)
        at com.google.android.gms.internal.zzff.zzfj(Unknown Source:39)
        at com.google.android.gms.internal.zzff.zzfi(Unknown Source:21)
        at com.google.android.gms.internal.zzff.zza(Unknown Source:4)
        at com.google.android.gms.ads.BaseAdView.loadAd(Unknown Source:6)
        at com.google.android.gms.ads.AdView.loadAd(Unknown Source:0)
        at <activity_name>.loadAdView(<activity_name>.java:2416)

据我所知,存在基于此 GitHub post and also filed in issue tracker 的问题。查看您遇到的问题是否与这些问题相关,并遵循给定的解决方法(如果有)。

附带说明,因为 SecurityException crash is usually due to reading gservices without permission. You may want to also try requesting permissions at Run Time

如果您还没有这样做,请注意,在 Android 的所有版本中,您的应用都需要在其应用清单中声明两类系统权限,即正常权限和危险权限。查看 declaring permissions 了解更多信息。

I'm using play services ads 10.2.6

始终确保您使用的是最新的库版本。

请更新到最新版本,目前为 11.0.2。

Firebase Android Release Notes