question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

IllegalStateException: The application's PagerAdapter changed the adapter's contents without calling PagerAdapter#notifyDataSetChanged! Expected adapter item count: 140, found: 150

See original GitHub issue

In the contributions activity, when opening any of my uploaded pictures I get the following crash either immediately or after changing screen orientation a few times. I can reproduce the crash easily, both in latest master and in branch marcosliberal:fix-issue-3906.

02-26 17:25:29.772 16399 16513 D OkHttp  : --> GET https://commons.wikimedia.org/w/api.php?action=query&format=json&formatversion=2&generator=allimages&gaisort=timestamp&gaidir=older&prop=imageinfo&iiprop=url|extmetadata|user&&iiurlwidth=640&iiextmetadatafilter=DateTime|Categories|GPSLatitude|GPSLongitude|ImageDescription|DateTimeOriginal|Artist|LicenseShortName|LicenseUrl&gaiuser=Syced&gailimit=10&gaicontinue=20210103154838|1%E6%9C%883%E6%97%A5(%E6%97%A5)%E3%81%AF%E6%9D%B1%E4%BA%AC%E3%82%BF%E3%83%AF%E3%83%BC%E3%82%92%E5%8F%B0%E6%B9%BE%E8%89%B2%E3%81%AB%E3%83%A9%E3%82%A4%E3%83%88%E3%82%A2%E3%83%83%E3%83%97_4.jpg&continue=gaicontinue||
02-26 17:25:29.774 16399 16513 D CookieManager: Domain:commons.wikimedia.org
02-26 17:25:29.793  5618  5825 D WifiStateMachine: enter getWifiLinkLayerStats
02-26 17:25:29.793  5618  5825 I WifiVendorHal: getWifiLinkLayerStats(l.2973) before calling iface.getLinkLayerStats
02-26 17:25:29.793  5144  5144 I android.hardware.wifi@1.0-service: enter getLinkLayerStats
02-26 17:25:29.793  5144  5144 I android.hardware.wifi@1.0-service: enter getLinkLayerStatsInternal
02-26 17:25:29.799 16399 16399 D AndroidRuntime: Shutting down VM
02-26 17:25:29.800 16399 16399 E AndroidRuntime: FATAL EXCEPTION: main
02-26 17:25:29.800 16399 16399 E AndroidRuntime: Process: fr.free.nrw.commons, PID: 16399
02-26 17:25:29.800 16399 16399 E AndroidRuntime: java.lang.IllegalStateException: The application's PagerAdapter changed the adapter's contents without calling PagerAdapter#notifyDataSetChanged! Expected adapter item count: 140, found: 150 Pager id: fr.free.nrw.commons:id/mediaDetailsPager Pager class: class androidx.viewpager.widget.ViewPager Problematic adapter: class fr.free.nrw.commons.media.MediaDetailPagerFragment$MediaDetailAdapter
02-26 17:25:29.800 16399 16399 E AndroidRuntime: 	at androidx.viewpager.widget.ViewPager.populate(ViewPager.java:1143)
02-26 17:25:29.800 16399 16399 E AndroidRuntime: 	at androidx.viewpager.widget.ViewPager.populate(ViewPager.java:1092)
02-26 17:25:29.800 16399 16399 E AndroidRuntime: 	at androidx.viewpager.widget.ViewPager$3.run(ViewPager.java:273)
02-26 17:25:29.800 16399 16399 E AndroidRuntime: 	at android.view.Choreographer$CallbackRecord.run(Choreographer.java:949)
02-26 17:25:29.800 16399 16399 E AndroidRuntime: 	at android.view.Choreographer.doCallbacks(Choreographer.java:761)
02-26 17:25:29.800 16399 16399 E AndroidRuntime: 	at android.view.Choreographer.doFrame(Choreographer.java:693)
02-26 17:25:29.800 16399 16399 E AndroidRuntime: 	at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:935)
02-26 17:25:29.800 16399 16399 E AndroidRuntime: 	at android.os.Handler.handleCallback(Handler.java:873)
02-26 17:25:29.800 16399 16399 E AndroidRuntime: 	at android.os.Handler.dispatchMessage(Handler.java:99)
02-26 17:25:29.800 16399 16399 E AndroidRuntime: 	at android.os.Looper.loop(Looper.java:214)
02-26 17:25:29.800 16399 16399 E AndroidRuntime: 	at android.app.ActivityThread.main(ActivityThread.java:7032)
02-26 17:25:29.800 16399 16399 E AndroidRuntime: 	at java.lang.reflect.Method.invoke(Native Method)
02-26 17:25:29.800 16399 16399 E AndroidRuntime: 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
02-26 17:25:29.800 16399 16399 E AndroidRuntime: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:965)

5 hours later, I get the same crash with different numbers: Expected adapter item count: 590, found: 600

I guess the app is somehow busy loading my thousands of past contributions, and miscalculating something while this happens. The crash might not be reproduced on account with few contributions. It does not happen in Explore either.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:12 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
misaochancommented, Jun 3, 2021

This occurs for me on 3.0-release branch even after cherrypicking #4354 onto it. It doesn’t even require me to switch orientation, sometimes it happens on start or when I swipe left to view the next picture.

STACK_TRACE=java.lang.IllegalStateException: The application's PagerAdapter changed the adapter's contents without calling PagerAdapter#notifyDataSetChanged! Expected adapter item count: 40, found: 50 Pager id: fr.free.nrw.commons:id/mediaDetailsPager Pager class: class androidx.viewpager.widget.ViewPager Problematic adapter: class fr.free.nrw.commons.media.MediaDetailPagerFragment$MediaDetailAdapter
at androidx.viewpager.widget.ViewPager.populate(ViewPager.java:1143)
at androidx.viewpager.widget.ViewPager.populate(ViewPager.java:1092)
at androidx.viewpager.widget.ViewPager.onMeasure(ViewPager.java:1622)
at android.view.View.measure(View.java:27131)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7951)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1552)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:842)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:721)
at android.view.View.measure(View.java:27131)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7951)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at android.view.View.measure(View.java:27131)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7951)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1552)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:842)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:721)
at android.view.View.measure(View.java:27131)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7951)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at android.view.View.measure(View.java:27131)
at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:735)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:481)
at android.view.View.measure(View.java:27131)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7951)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1552)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:842)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:721)
at android.view.View.measure(View.java:27131)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7951)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at androidx.appcompat.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:143)
at android.view.View.measure(View.java:27131)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7951)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1552)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:842)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:721)
at android.view.View.measure(View.java:27131)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7951)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at android.view.View.measure(View.java:27131)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7951)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1552)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:842)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:721)
at android.view.View.measure(View.java:27131)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7951)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at com.android.internal.policy.DecorView.onMeasure(DecorView.java:1173)
at android.view.View.measure(View.java:27131)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:4139)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:2893)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:3156)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:2575)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:9910)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1010)
at android.view.Choreographer.doCallbacks(Choreographer.java:809)
at android.view.Choreographer.doFrame(Choreographer.java:744)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:995)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:246)
at android.app.ActivityThread.main(ActivityThread.java:8506)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
1reaction
vinayak0505commented, Apr 16, 2021

@nicolas-raoul I think this is also resolved ??

Read more comments on GitHub >

github_iconTop Results From Across the Web

The application's PagerAdapter changed the adapter's content ...
IllegalStateException : The application's PagerAdapter changed the adapter's content without calling PagerAdapter#notifyDataSetChanged! Expected adapter item ...
Read more >
without calling PagerAdapter#notifyDataSetChanged! - MSDN
IllegalStateException : The application's PagerAdapter changed the adapter's contents without calling PagerAdapter#notifyDataSetChanged!
Read more >
The application's PagerAdapter changed the adapter's ...
The application's PagerAdapter changed the adapter's contents without calling PagerAdapter#notifyDataSetChanged.
Read more >
Migrate from ViewPager to ViewPager2 - Android Developers
If your app already uses ViewPager , read this page to learn more about migrating to ViewPager2 . If you want to use...
Read more >
viewpager/src/main/java/androidx/viewpager/widget ...
throw new IllegalStateException("The application's PagerAdapter changed the adapter's". + " contents without calling PagerAdapter#notifyDataSetChanged!".
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found