问题
Since last week i'm getting a fatal error in my app in production release due some admob bug
Fatal Exception: java.lang.NullPointerException: Attempt to read from field 'com.google.android.gms.ads.internal.overlay.n com.google.android.gms.ads.internal.overlay.AdOverlayInfoParcel.c' on a null object reference
at com.google.android.gms.ads.internal.overlay.k.f(k.java)
at com.google.android.gms.ads.internal.overlay.client.b.a(b.java:1)
at fy.onTransact(fy.java:4)
at android.os.Binder.transact(Binder.java:662)
at com.google.android.gms.internal.ads.zzgu.zzb(zzgu.java:21)
at com.google.android.gms.internal.ads.zzarl.onUserLeaveHint(zzarl.java:54)
at com.google.android.gms.ads.AdActivity.onUserLeaveHint(AdActivity.java:32)
at android.app.Activity.performUserLeaving(Activity.java:7470)
at android.app.Instrumentation.callActivityOnUserLeaving(Instrumentation.java:1476)
at android.app.ActivityThread.performUserLeavingActivity(ActivityThread.java:4034)
at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:4016)
at android.app.servertransaction.PauseActivityItem.execute(PauseActivityItem.java:45)
at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:145)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:70)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1839)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:201)
at android.app.ActivityThread.main(ActivityThread.java:6864)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)
I was not able to reproduce the problem in test. but as the stack shows it is caused due some inner call of the admob api responding to android native events.
the versions i'm using:
'com.google.gms:google-services:4.3.4'
api "com.google.android.gms:play-services-location:17.1.0"
api 'com.google.android.gms:play-services-ads:19.5.0'
回答1:
Best is try logging the Ad response id to basically see if there is a certain type of Ad crashing the App. If yes you need to search for Ad in Ad manager and block it from serving. https://developers.google.com/ad-manager/mobile-ads-sdk/android/crashlytics
来源:https://stackoverflow.com/questions/64638098/admob-causes-nullpointerexception-in-android-apps