Fatal Exception: java.lang.NullPointerException nativeAd.body must not be null
See original GitHub issuePlugin Version
0.13.0
Steps to Reproduce
- Log captured by Crashlytics from live Android app.
Expected results: Native ads should be displayed in Android app without crashing
Actual results: Android app is crashing with Fatal Exception: java.lang.NullPointerException nativeAd.body must not be null
Logs
Fatal Exception: java.lang.NullPointerException: nativeAd.body must not be null at com.app.ListTileNativeAdFactory.createNativeAd(ListTileNativeAdFactory.java:190) at io.flutter.plugins.googlemobileads.FlutterNativeAd$1.onNativeAdLoaded(FlutterNativeAd.java:12) at com.google.android.gms.internal.ads.zzatv.zze(zzatv.java:7) at com.google.android.gms.internal.ads.zzait.zzbA(zzait.java:31) at com.google.android.gms.internal.ads.zzhx.onTransact(zzhx.java:20) at android.os.Binder.transact(Binder.java:675) at fu.bi(fu.java:2) at com.google.android.gms.ads.internal.formats.client.ak.e(ak.java) at com.google.android.gms.ads.nonagon.ad.nativead.ad.run(ad.java:5) at android.os.Handler.handleCallback(Handler.java:873) at android.os.Handler.dispatchMessage(Handler.java:99) at apc.a(apc.java) at com.google.android.gms.ads.internal.util.zzae.a(zzae.java:1) at apc.dispatchMessage(apc.java) at android.os.Looper.loop(Looper.java:214) at android.app.ActivityThread.main(ActivityThread.java:7094) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:975)
Issue Analytics
- State:
- Created 2 years ago
- Comments:5
Top GitHub Comments
Thanks! This worked! The codelab from google does not work.
you have to check if body is null in your Ad factory (code in Kotlin)
if (nativeAd.body?.isNotEmpty() == true) {
text = nativeAd.body
visibility = View.VISIBLE
} else {
View.INVISIBLE
}