Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WrongFragmentContainerViolation with TransactionOverviewFragment #774

Open
wbervoets opened this issue Feb 17, 2022 · 5 comments
Open

WrongFragmentContainerViolation with TransactionOverviewFragment #774

wbervoets opened this issue Feb 17, 2022 · 5 comments

Comments

@wbervoets
Copy link

wbervoets commented Feb 17, 2022

✍️ 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

  1. Make sure your app is using AndroidX Fragment 1.4.1 + enabled FragmentStrictMode checks
  2. Click on Chucker notification
  3. Click on a transaction from the transaction list
  4. 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

@vbuberen
Copy link
Collaborator

vbuberen commented Feb 17, 2022

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 with ViewPager, because ViewPager2 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.

@wbervoets
Copy link
Author

Thanks for the clarification. For now I'll disable the WrongFragmentContainer check when I need the Chucker functionality.

Am I correct to assume that the issues you were experiencing with Viewpager2 are fixed in the 1.1.x series? (so we need to wait until ViewPager2 1.1.0 gets a final release)

@wbervoets
Copy link
Author

maybe we should ping @jfresen from Google @to see if a 1.1 release is coming in the near future ? :-)

@vbuberen
Copy link
Collaborator

Am I correct to assume that the issues you were experiencing with Viewpager2 are fixed in the 1.1.x series?

Note, it is mostly a speculation from my side that ViewPager2 resolves the issue with Strict mode

As long as I remember we had only one of issues with options menu flickering resolved back then. However, I used alpha builds at that time. Maybe something changed with beta version.
Among other issues we had were:

  1. Wrong options menu items, which I mentioned in the mentioned PR with migration.
  2. Some UX issue, which is described here: https://medium.com/@BladeCoder/fixing-recyclerview-nested-scrolling-in-opposite-direction-f587be5c1a04

Looking at dates of releases of ViewPager2 I doubt that we will see a stable release soon. It is already a few years passed since 1.0 release and 1.1 isn't a plan, probably, since focus might be shifted from such libraries to Jetpack Compose. So my expectation is that Chucker will migrate to Jetpack Compose faster than Google releases ViewPager2 😄

@jfresen
Copy link

jfresen commented Feb 23, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants