IndexOutOfBoundException when receiving Google Native Ads without images


#1

Hi,

A crash surfaced after we integrated Google Native Ads Advanced recently.

Fatal Exception: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
       at java.util.ArrayList.get(ArrayList.java:411)
       at com.mopub.nativeads.GooglePlayServicesNative$GooglePlayServicesNativeAd.isValidContentAd(Unknown Source)
       at com.mopub.nativeads.GooglePlayServicesNative$GooglePlayServicesNativeAd.access$400(Unknown Source)
       at com.mopub.nativeads.GooglePlayServicesNative$GooglePlayServicesNativeAd$3.onContentAdLoaded(Unknown Source)

Based on the information on Google’s page:
https://developers.google.com/android/reference/com/google/android/gms/ads/formats/NativeContentAd
Images seems to be a recommended field only.

We believed there are chances that Google serves native ads without any image as an empty ArrayList which leads to this crash.

David


#2

Hi @david_cheng,

Thanks for reaching out. Do you have the unobfuscated stack trace so we can see the line numbers that the app is crashing on? Also, are you mediating AdMob native ads or DFP native ads? AdMob native ads should always be returned with at least one image asset.

We do have a fix in place that we plan to incorporate. It should be deployed with the adapter with the next MoPub SDK release. Stay tuned!


#3

Hi @chauduyphanvu,

In fact we later realized someone had already filed a pull request which resolved exactly the same issue we are encountering.

We are mediating Admob native advanced, but the crash did hit quite a significant share of our users.

David


#4

Got it - thanks! We will be merging this change internally and evaluating it. It should be deployed with the next release of the MoPub SDK.

Cheers,
Vu