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

IllegalStateException: Views added to a FragmentContainerView must be associated with a Fragment. #179

Closed
victorhvs-iabcd opened this issue Oct 7, 2020 · 3 comments

Comments

@victorhvs-iabcd
Copy link

Describe the bug
I'm facing illegalStateException after the upgrade of my project to kotlin 1.4 and jetpack libs.

To Reproduce
My code:
MaterialTapTargetPrompt.Builder(this@HomeFragment).setTarget(R.id.lp_layout).setPrimaryText("Olá").show()

Stack trace
2020-10-07 11:33:07.925 6505-6505/br.org.institutoabcd.edu.dev E/AndroidRuntime: FATAL EXCEPTION: main Process: br.org.institutoabcd.edu.dev, PID: 6505 java.lang.IllegalStateException: Views added to a FragmentContainerView must be associated with a Fragment. View uk.co.samuelwall.materialtaptargetprompt.MaterialTapTargetPrompt$PromptView{dcefcb5 VFED..... .F....ID 0,0-0,0 #7f0a03f8 app:id/material_target_prompt_view} is not associated with a Fragment. at androidx.fragment.app.FragmentContainerView.addView(FragmentContainerView.java:276) at android.view.ViewGroup.addView(ViewGroup.java:4875) at android.view.ViewGroup.addView(ViewGroup.java:4848) at uk.co.samuelwall.materialtaptargetprompt.MaterialTapTargetPrompt.show(MaterialTapTargetPrompt.java:274) at uk.co.samuelwall.materialtaptargetprompt.extras.sequence.SequenceItem.show(SequenceItem.java:175) at uk.co.samuelwall.materialtaptargetprompt.extras.sequence.SequenceItem.show(SequenceItem.java:136) at uk.co.samuelwall.materialtaptargetprompt.MaterialTapTargetSequence.show(MaterialTapTargetSequence.java:234) at uk.co.samuelwall.materialtaptargetprompt.MaterialTapTargetSequence.show(MaterialTapTargetSequence.java:210) at br.org.institutoabcd.edu.presentation.ui.home.HomeFragment.showTour(HomeFragment.kt:341) at br.org.institutoabcd.edu.presentation.ui.home.HomeFragment.access$showTour(HomeFragment.kt:38) at br.org.institutoabcd.edu.presentation.ui.home.HomeFragment$setupViews$6.onClick(HomeFragment.kt:141) at android.view.View.performClick(View.java:7125) at android.view.View.performClickInternal(View.java:7102) at android.view.View.access$3500(View.java:801) at android.view.View$PerformClick.run(View.java:27336) at android.os.Handler.handleCallback(Handler.java:883) at android.os.Handler.dispatchMessage(Handler.java:100) at android.os.Looper.loop(Looper.java:214) at android.app.ActivityThread.main(ActivityThread.java:7356) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)

Smartphone (please complete the following information):

  • Device: Pixel 4
  • OS: API 29
  • Library version 3.0.0
  • Kotlin version 1.4

Additional context
Instead of using fragment, I'm using activity and this solves the problem..

@JMavrelos
Copy link
Contributor

I got this too, this seems to be because of the navigation api

in show()

the code that gets the parent is

final ViewGroup parent = mView.mPromptOptions.getResourceFinder().getPromptParentView();

which returns the FragmentContainerView used as a navigation host

when I replaced it with

final ViewGroup parent = (ViewGroup)mView.mPromptOptions.getTargetView().getParent();

(which ofc is only correct in my project, because I know that the target view is inside the fragment I wish to target)

it works correctly

@JMavrelos
Copy link
Contributor

I created a pull request that solves the problem (for me) so when/if it gets approved it should work for you too

#180

@sjwall
Copy link
Owner

sjwall commented Oct 23, 2020

Fixed by #180

@sjwall sjwall closed this as completed Oct 23, 2020
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