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.

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

  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

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
jfresencommented, 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.

1reaction
vbuberencommented, 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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Debug your fragments | Android Developers
The wrong fragment container violation is enabled using detectWrongFragmentContainer() and throws a WrongFragmentContainerViolation . This ...
Read more >
Error using <FragmentContainerView>, but no error with ...
Step 1 : Add FragmentContainerView to your activity xml <androidx.fragment.app.FragmentContainerView android:id="@+id/container" ...
Read more >
Fragment related pitfalls and how to avoid them : r/androiddev
Fix - Before doing FragmentTransaction#commit , check that the activity has not been destroyed - Activity#isDestroyed() should return false ...
Read more >
StrictMode: Expand Violation classes to contain structured ...
The base Violation class should have a getFragment() method that returns a NonNull Fragment instance that caused the Violation. Examples of information I'd ......
Read more >
Components of android? Fragments? How to send msg ... - Glassdoor
It will not be wrong if we say, a fragment is a kind of sub-activity. ... beginTransaction().add(R.id.container, ldf).commit(); //Retrieve the value String ...
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