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.

Fatal Exception: java.lang.IllegalStateException

See original GitHub issue

Please complete the following information:

  • Library Version 1.2.9
  • Affected Device(s) Samsung, Xiaomi, HUAWEI, OPPO OS 8,9,10

The Bug:

I’m using only showAlignTop method, but in some cases this crash is popping on my Firebase Crashlytics.

The specified child already has a parent. You must call removeView() on the child's parent first.

Fatal Exception: java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
       at android.view.ViewGroup.addViewInner(ViewGroup.java:5106)
       at android.view.ViewGroup.addView(ViewGroup.java:4935)
       at android.view.ViewGroup.addView(ViewGroup.java:4907)
       at android.widget.PopupWindow.createBackgroundView(PopupWindow.java:1530)
       at android.widget.PopupWindow.preparePopup(PopupWindow.java:1492)
       at android.widget.PopupWindow.showAsDropDown(PopupWindow.java:1417)
       at android.widget.PopupWindow.showAsDropDown(PopupWindow.java:1380)
       at com.skydoves.balloon.Balloon$showAlignTop$$inlined$show$1.run(Balloon.java:1774)
       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:7403)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:935)

Possible solution:

Was not able to full reproduce yet, but maybe we can find the right part of the library and to some parent check, like

if(tv.getParent() != null) {
    ((ViewGroup)tv.getParent()).removeView(tv); // <- fix
}
layout.addView(tv);

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
Canatocommented, Feb 2, 2021

100% safe @skydoves thanks for the fast responsive on this. muzmatch working like an charm

1reaction
skydovescommented, Feb 1, 2021

@Canato Hmm… I think the balloon should be shown when the contentView has no parent view for preventing the concurrency issue. I will test and add some more conditions on the show method. Thanks for your report 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

java.lang.IllegalStateException: Can not perform this action ...
Fatal Exception : java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState at android.support.v4.app.
Read more >
How to Fix The IllegalStateException in Java - Rollbar
An IllegalStateException is a runtime exception in Java that is thrown to indicate that a method has been invoked at the wrong time....
Read more >
IllegalStateException - Android Developers
java.lang.Object. ↳, java.lang.Throwable. ↳, java.lang.Exception. ↳, java.lang.RuntimeException. ↳, java.lang.IllegalStateException ...
Read more >
How to Solve java.lang.IllegalStateException in Java main ...
IllegalStateException is the child class of RuntimeException and hence it is an unchecked exception. This exception is rise explicitly by ...
Read more >
java.lang.IllegalStateException: could not load open ssl
We have an Android app that is hosted internally via Workspace ONE UEM. It uses the Android SDK 21.11 and is working well....
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