WrongFragmentContainerViolation with TransactionOverviewFragment
See original GitHub issue✍️ Describe the bug
When clicking on a transaction Chucker crashes with the following exception:
Fatal Exception: androidx.fragment.app.strictmode.WrongFragmentContainerViolation Attempting to add fragment TransactionOverviewFragment{ff4002b} (ab14c612-b5e4-41c1-8a05-05a1816b3c62 id=0x7f0a037c) to container androidx.viewpager.widget.ViewPager{3b95f96 VFED… …I. 0,0-0,0 #7f0a037c app:id/viewPager} which is not a FragmentContainerView
I’m using AndroidX Fragment 1.4.1 and have enabled following strictmode checks:
FragmentStrictMode.defaultPolicy = FragmentStrictMode.Policy.Builder() .detectFragmentReuse() .detectFragmentTagUsage() .detectRetainInstanceUsage() .detectSetUserVisibleHint() .detectTargetFragmentUsage() .detectWrongFragmentContainer() .penaltyDeath() .build()
💣 Steps to reproduce
- Make sure your app is using AndroidX Fragment 1.4.1 + enabled FragmentStrictMode checks
- Click on Chucker notification
- Click on a transaction from the transaction list
- Crashes with WrongFragmentContainerViolation Attempting to add fragment TransactionOverviewFragment
🔧 Expected behavior
Show the details of the transaction
📱 Tech info
- Device: All devices
- OS: Android 10
- Chucker version: 4.0.0-SNAPSHOT
📄 Additional context
Using app with Fragment 1.4.1
Issue Analytics
- State:
- Created 2 years ago
- Comments:5
Top GitHub Comments
Hi. Yes, our focus has shifted to Jetpack Compose indeed. If you are planning to migrate to Compose, that is probably the best option for you.
Thanks for your report.
I saw this issue, but the problem there is that this fragment is part of
ViewPager
and we decided to stick withViewPager
, becauseViewPager2
had some issues (see more in #159).So, I guess, till we migrate to some newer version of
ViewPager2
(I suppose lint/strict mode won’t complain about same issue there), which, probably, won’t be released by Google anytime soon if at all, we can’t get away from this problem.