NullPointerException on nativeAds when calling HeadlineView().setText(nativeAd.getHeadline())

120 views
Skip to first unread message

Wing Chan

unread,
Feb 29, 2020, 9:46:49 PM2/29/20
to Google Mobile Ads SDK Developers
I got a NullPointerException reported when I try to call below function

245: ((TextView) adView.getHeadlineView()).setText(nativeAd.getHeadline());

and HeadlineView defined as below under populateUnifiedNativeAdView(UnifiedNativeAd nativeAd, UnifiedNativeAdView adView)

adView.setHeadlineView(adView.findViewById(R.id.ad_headline));

But this error just sometimes happens, not every time, thanks. 

Error as below:

Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.TextView.setText(java.lang.CharSequence)' on a null object reference
       at XXXX.populateUnifiedNativeAdView(XXX.java:245)
       at XXXX.access$400(XXX.java:52)
       at XXXX$3.onUnifiedNativeAdLoaded(FragmentLatest.java:187)
       at com.google.android.gms.internal.ads.zzaer.zza(com.google.android.gms:play-services-ads-lite@@18.3.0:6)
       at com.google.android.gms.internal.ads.zzady.zza(com.google.android.gms:play-services-ads-lite@@18.3.0:18)
       at com.google.android.gms.internal.ads.zzgb.onTransact(com.google.android.gms:play-services-ads-base@@18.3.0:13)
       at android.os.Binder.transact(Binder.java:674)
       at fe.b(:com.google.android.gms.policy_ads_fdr_dynamite@21207004@21207004.283464268.283464268:2)
       at com.google.android.gms.ads.internal.formats.client.aw.a(:8)
       at com.google.android.gms.ads.nonagon.ad.nativead.ae.run(:com.google.android.gms.policy_ads_fdr_dynamite@21207004@21207004.283464268.283464268:7)
       at android.os.Handler.handleCallback(Handler.java:873)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at oz.a()
       at com.google.android.gms.ads.internal.util.f.a(:com.google.android.gms.policy_ads_fdr_dynamite@21207004@21207004.283464268.283464268:1)
       at oz.dispatchMessage()
       at android.os.Looper.loop(Looper.java:224)
       at android.app.ActivityThread.main(ActivityThread.java:7060)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:536)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:928)

Please help, many thanks.

Mobile Ads SDK Forum Advisor Prod

unread,
Mar 2, 2020, 12:35:03 AM3/2/20
to win...@gmail.com, google-adm...@googlegroups.com

Hi Wing,

 

Thank you for reaching out to us, and for providing extensive details on your concern.

 

My first guess on why this issue occurs is due to AdMob SDK receiving native ads without a headline part (or due to it being unable to receive native ads at all), resulting in null references being thrown. With that in mind, could you kindly provide the details below (via Reply privately to author) so that I can further investigate the issue?

  • Ad unit IDs affected
  • Copy of your sample project (replicating the issue)
  • Steps to reproduce the issue

 

Regards,

Ziv Yves Sanchez

Mobile Ads SDK Team



ref:_00D1U1174p._5001UXTkEY:ref
Reply all
Reply to author
Forward
0 new messages