clockbyte / admobadapter

It wraps your Adapter to display Admob native ads and banners in a ListView/RecyclerView data set. It based on the Yahoo fetchr project https://github.com/yahoo/fetchr
Apache License 2.0
237 stars 75 forks source link

Fatal Exception: java.lang.IllegalStateException #119

Open lpbas opened 6 years ago

lpbas commented 6 years ago

Admobadapter version or commit: Latest (v1.4.6)

Android compileSdkVersion: 27

Issue description briefly: After deploying the library on my app, I get the following exception:

Fatal Exception: java.lang.IllegalStateException
The content of the adapter has changed but ListView did not receive a notification. Make sure the content of your adapter is not modified from a background thread, but only from the UI thread. Make sure your adapter calls notifyDataSetChanged() when its content changes. [in ListView(2131296540, class android.widget.ListView) with Adapter(class com.clockbyte.admobadapter.bannerads.AdmobBannerAdapterWrapper)]

Steps to reproduce: I have not been able to reproduce this locally, so I do not know how to reproduce this.

I'm trying to figure out if this is a problem with the library, the ads, or my original adapter. Please keep in mind that I never got a crash report regarding my adapters before adding the admobAdapterWrapper in my app, and that's why I dont think it has to do with my adapter.

If you have any ideas/suggestions, please let me know.

kot331107 commented 6 years ago

@L4grange please pay attention to all the places where you get a response from your webservice (or something) and try to update results to your adapter (wrapped with banner wrapper adapter). Do you update it in the UI thread (as error message suggests)? Could you please make some test project to reproduce it and share with me?

lpbas commented 6 years ago

Unfortunately I can't reproduce the issue locally, this is comming from my crashlytics crash reports. I will go tomorrow over every single adapter notificaiton and make sure once again.

As I've seen your code, I know that all your calls to notifyDataStateChanged() are on the main thread, I'm trying to figure out what's wrong with my adapters combined with the admobWrapper.

I will let you know when I have more info, thank you for your help!

kot331107 commented 6 years ago

@L4grange Hi, Okay, waiting for your update :)

HaydenCampbell commented 5 years ago

I am getting the same error: java.lang.IllegalStateException: The content of the adapter has changed but ListView did not receive a notification. Make sure the content of your adapter is not modified from a background thread, but only from the UI thread. Make sure your adapter calls notifyDataSetChanged() when its content changes. [in ListView(2131230874, class android.widget.ListView) with Adapter(class com.clockbyte.admobadapter.bannerads.AdmobBannerAdapterWrapper)]

Steps to reproduce:

It's kind of hard to reproduce:

  1. Fling/scroll listview super fast
  2. Stop scroll suddenly at an area where adview will appear
  3. Click a listitem quickly before adview appears

I am using the admob mediation with facebook ads so this could have something to do with it.