Throw Null Pointer Exception when going to load ad in some android devices

543 views
Skip to first unread message

Abdur Rehman

unread,
Nov 17, 2020, 12:04:16 AM11/17/20
to Google Mobile Ads SDK Developers
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:676)
       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:7353)
       at android.app.Instrumentation.callActivityOnUserLeaving(Instrumentation.java:1497)
       at android.app.ActivityThread.performUserLeavingActivity(ActivityThread.java:4169)
       at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:4154)
       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:1977)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loop(Looper.java:220)
       at android.app.ActivityThread.main(ActivityThread.java:6929)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:870)




in android devices:  moto g(8) play, Galaxy J4, Galaxy J6, Galaxy J6+, Mi A2 Lite, 
Nokia 7.1, Galaxy A7(2017) etc.

I'm using:  implementation 'com.google.firebase:firebase-ads:19.5.0'




Mobile Ads SDK Forum Advisor Prod

unread,
Nov 17, 2020, 3:36:54 AM11/17/20
to fita...@gmail.com, google-adm...@googlegroups.com

Hi Abdur,

Thank you for reaching out to us.

Could you kindly provide the details below (via Reply to author, or a direct, private reply to this email) so that I can investigate the issue?

  • Android versions of affected devices
  • Copy of a modified sample app (replicating the issue)
  • Steps to replicate the issue

 

Google Logo
Ziv Yves Sanchez
Mobile Ads SDK Team
 


ref:_00D1U1174p._5004Q27uOtF:ref

Abdur Rehman

unread,
Nov 18, 2020, 12:20:35 AM11/18/20
to Google Mobile Ads SDK Developers
I'm receiving different types of crashes in my application when user just open main activity after closing splash activity, this is my application link. 

play store link  in 1.0.8 version,  these crashes occur when I updated admob dependency to version 19.5.0. 

First Crash
crash occur at:
fy.java line 4
fy.onTransact  

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:914)
       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:8161)
       at android.app.Instrumentation.callActivityOnUserLeaving(Instrumentation.java:1518)
       at android.app.ActivityThread.performUserLeavingActivity(ActivityThread.java:4650)
       at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:4635)
       at android.app.servertransaction.PauseActivityItem.execute(PauseActivityItem.java:46)
       at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176)
       at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2147)
       at android.os.Handler.dispatchMessage(Handler.java:107)
       at android.os.Looper.loop(Looper.java:237)
       at android.app.ActivityThread.main(ActivityThread.java:7814)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1075)

android version                     model 
10                                            Galaxy A11 
10                                            Galaxy A71  
9                                               moto g(8) play  
9                                               Galaxy J4  
10                                             Galaxy S9
10                                             Galaxy J6
10                                             Galaxy J6+  
9                                               Redmi Note 8T
9                                               A1k
10                                            Mi A2 Lite
10                                            Nokia 7.1
9                                              Galaxy A7(2017)
10                                            Galaxy A10
9                                              Galaxy J7 Star
9                                              Galaxy A50
9                                              Xperia XA2





Second Crash 
crash occur at:
gg.java line 4
gg.onTransact  

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 gg.onTransact(gg.java:4)
       at android.os.Binder.transact(Binder.java:627)
       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:7283)
       at android.app.Instrumentation.callActivityOnUserLeaving(Instrumentation.java:1418)
       at android.app.ActivityThread.performUserLeavingActivity(ActivityThread.java:4142)
       at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:4102)
       at android.app.ActivityThread.-wrap15(ActivityThread.java)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1789)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loop(Looper.java:166)
       at android.app.ActivityThread.main(ActivityThread.java:6861)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:450)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)


android version                     model
 10                                           smartphone Galaxy A11  
 8.1.0                                       smartphone HUAWEI Y5 lite  
 8.1.0                                       smartphone CPH1909  
8.1.0                                        smartphone HUAWEI Y5 2018  
8.1.0                                        smartphone Galaxy J2 Core  
6.0                                           smartphone GR3 2017  
8.1.0                                        smartphone Fortune 2  





Third Crash
crash occur at:
fx.java line 4
fx.onTransact  

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 fx.onTransact(fx.java:4)
       at android.os.Binder.transact(Binder.java:914)
       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:8163)
       at android.app.Instrumentation.callActivityOnUserLeaving(Instrumentation.java:1518)
       at android.app.ActivityThread.performUserLeavingActivity(ActivityThread.java:4784)
       at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:4769)
       at android.app.servertransaction.PauseActivityItem.execute(PauseActivityItem.java:46)
       at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176)
       at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2220)
       at android.os.Handler.dispatchMessage(Handler.java:107)
       at android.os.Looper.loop(Looper.java:237)
       at android.app.ActivityThread.main(ActivityThread.java:8019)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100)


android version : 10                            device model : Galaxy A51  

Mobile Ads SDK Forum Advisor Prod

unread,
Nov 18, 2020, 3:25:07 AM11/18/20
to fita...@gmail.com, google-adm...@googlegroups.com

Hi Abdur,

I’m with Ziv’s team and thanks for sharing the link.

I was able to download and install the app on my device (Pixel 3 XL - Android 11) successfully. However, I’m not able to see any of the crash issues that you are experiencing. Are there any steps on how to replicate the issue? Please let us know so we can continue to investigate.

Regards,

Google Logo
Sherwin Diesta
Mobile Ads SDK Team
 


ref:_00D1U1174p._5004Q27uOtF:ref

Abdur Rehman

unread,
Nov 18, 2020, 4:02:22 AM11/18/20
to Google Mobile Ads SDK Developers
you not tried to install app on devices that I listed above, please try to install app on above devices.

Mobile Ads SDK Forum Advisor Prod

unread,
Nov 18, 2020, 10:46:25 AM11/18/20
to fita...@gmail.com, google-adm...@googlegroups.com
Hi Abdur,

Thank you for responding back to us regarding this. I work along with Sherwin. As such I will be helping you today with this. Having read over this issue, would it be possible for you to also send us a simple sample with your implementation. So that we can test against the code. It is better for us to use codebase and not the actual app. From what we are seeing it has been working properly, which would indicate no issue with the implementation or our system. But seems to be more of an issue related to the devices.

Regards,
Google Logo
William Pescherine
Mobile Ads SDK Team
 


ref:_00D1U1174p._5004Q27uOtF:ref

Abdur Rehman

unread,
Nov 19, 2020, 6:30:52 AM11/19/20
to Google Mobile Ads SDK Developers

private fun Context.adSize(pAdViewContainer: FrameLayout): AdSize? {
    val display = (this as Activity).windowManager.defaultDisplay
    val outMetrics = DisplayMetrics()
    display.getMetrics(outMetrics)

    val density = outMetrics.density

    var adWidthPixels = pAdViewContainer.width.toFloat()
    if (adWidthPixels == 0f) {
        adWidthPixels = outMetrics.widthPixels.toFloat()
    }

    val adWidth = (adWidthPixels / density).toInt()
    return AdSize.getCurrentOrientationAnchoredAdaptiveBannerAdSize(this, adWidth)
}

fun Activity.loadAdmobAdaptiveBannerForOpenPdf(
    pAdViewContainer: FrameLayout
) {
    try {
        val adView = AdView(this)
        adView.adUnitId = resources.getString(R.string.admob_banner_viewer_id)
        val adSize = adSize(pAdViewContainer)
        adView.adSize = adSize


        val adRequest = AdRequest.Builder().build()
        // Start loading the ad in the background.
        adView.loadAd(adRequest)
        adView.adListener = object : AdListener() {
            override fun onAdLoaded() {
                super.onAdLoaded()
                pAdViewContainer.removeAllViews()
                pAdViewContainer.addView(adView)
            }

            override fun onAdFailedToLoad(p0: Int) {
                super.onAdFailedToLoad(p0)
                Timber.e("loadAdmobAdaptiveBannerForOpenPdf error: ${p0}")
                loadFbBannerForOpenPdf(pAdViewContainer)
            }
        }

    } catch (e: Exception) {
        Timber.e(e)
    } catch (e: Error) {
        Timber.e(e)

Abdur Rehman

unread,
Nov 19, 2020, 6:32:31 AM11/19/20
to Google Mobile Ads SDK Developers
fun Context.loadAdmobAdaptiveBannerForMain(pAdViewContainer: FrameLayout) {
    try {
        val adView = AdView(this)
        adView.adUnitId = resources.getString(R.string.admob_banner_id)
        adView.adSize = adSize(pAdViewContainer)
        pAdViewContainer.removeAllViews()
        pAdViewContainer.addView(adView)

        val adRequest = AdRequest.Builder().build()
        // Start loading the ad in the background.
        adView.loadAd(adRequest)
        adView.adListener = object : AdListener() {
            override fun onAdFailedToLoad(p0: Int) {
                super.onAdFailedToLoad(p0)
                Timber.e("loadAdmobAdaptiveBanner error: ${p0}")
                loadFbBannerr(pAdViewContainer)

Mobile Ads SDK Forum Advisor Prod

unread,
Nov 19, 2020, 12:38:14 PM11/19/20
to fita...@gmail.com, google-adm...@googlegroups.com
Hi Abdur,

I work with Sherwin and will assist you. Thank you for showing us your implementation. Are you able to reliably replicate this crash? If so, could you give us a project based on our Sample Kotlin Adaptive Banner app with minimum extra code added for reliable reproduction of the overlay crash? You may send us a shareable link to it via "Reply to author". If "Reply to author" is unavailable you may send that link to our testing alias mobileads...@gmail.com with a reply on this thread when doing so.

Regards,

Google Logo
Aryeh Baker
Mobile Ads SDK Team
 


ref:_00D1U1174p._5004Q27uOtF:ref

Joe wang

unread,
Nov 23, 2020, 1:51:14 AM11/23/20
to Google Mobile Ads SDK Developers
we have same issue with admob 19.5.0. And admob 19.3.0 is working well. 

Mobile Ads SDK Forum Advisor Prod

unread,
Nov 23, 2020, 4:13:36 AM11/23/20
to joe....@kikatech.com, google-adm...@googlegroups.com

Hi there,

Thank you for your message. However, just like what my colleague requested previously, we need a sample project file (based on our Sample Kotlin Adaptive Banner app) for our test reference, and so we could investigate further. You can share the file via Reply to author, or a direct, private reply to this email.



Regards,


 

Google Logo
Sherwin Diesta
Mobile Ads SDK Team
 


ref:_00D1U1174p._5004Q27uOtF:ref

Joe wang

unread,
Nov 23, 2020, 9:06:56 PM11/23/20
to Google Mobile Ads SDK Developers
https://groups.google.com/g/google-admob-ads-sdk/c/RFqByF8TnwE/m/5S1lQk8EBgAJ
this crash call stack look like our crash.  that one happened on onConfigurationChanged, our is onUserLeaveHint.
 Maybe we can make a similar fix

Mobile Ads SDK Forum Advisor Prod

unread,
Nov 24, 2020, 3:02:36 AM11/24/20
to joe....@kikatech.com, google-adm...@googlegroups.com

Hi Joe,

Thanks for reaching out to us. Could you please share with us the stack trace that you have, so we can compare it as well? Please don't forget to use the Reply to author option, or you can send the information by replying to this email privately.

Regards,

Mobile Ads SDK Forum Advisor Prod

unread,
Dec 9, 2020, 10:12:40 AM12/9/20
to fita...@gmail.com, google-adm...@googlegroups.com
Hi everyone,

Thank you for reporting this crash, I brought this  up to with my team and we are investigating it. Anyone who knows methods of replication, devices happening on, Android versions happening on or statistics etc.. could help everyone out by reporting it. We will get back to you as soon as we have more information.

Regards,

Google Logo
Aryeh Baker
Mobile Ads SDK Team
 


ref:_00D1U1174p._5004Q27uOtF:ref

Mobile Ads SDK Forum Advisor Prod

unread,
Mar 1, 2021, 1:44:41 PM3/1/21
to fita...@gmail.com, joe....@kikatech.com, google-adm...@googlegroups.com
Hi Abdur and Joe,

I have good news, my team has reported that this crash has subsided substantially and will continue to improve. Please report back to us if you are still seeing the crash.
Reply all
Reply to author
Forward
0 new messages