- android.view.WindowManager$BadTokenException: Unable to add window — token null is not valid; is your activity running? #92
- Comments
- epool commented Aug 14, 2020
- skydoves commented Aug 15, 2020 •
- epool commented Aug 17, 2020 •
- skydoves commented Oct 7, 2020
- znakeeye commented Oct 16, 2020
- sembozdemir commented Oct 19, 2020
- skydoves commented Nov 7, 2020
- znakeeye commented Nov 10, 2020
android.view.WindowManager$BadTokenException: Unable to add window — token null is not valid; is your activity running? #92
Comments
epool commented Aug 14, 2020
Please complete the following information:
- Library Version [v1.1.9]
- Affected Device(s) [General]
Describe the Bug:
We are receiving this crash in our crashlytics console
This is a dummy implementation of our view for a reference implementation:
Expected Behavior:
Don’t receive these crashes.
The text was updated successfully, but these errors were encountered:
skydoves commented Aug 15, 2020 •
Hi, @epool !
Could you test using this way?
I think your Activity is destroyed but still seems to show and reference the destroyed Activity’s context.
Or the custom view is used in a fragment?
epool commented Aug 17, 2020 •
@skydoves yes, it’s being used in an Activity. The reason why I’m not using myLifeCycle.handleLifecycleEvent(Lifecycle.Event.ON_DESTROY) is because the custom view is being added and removed from its parent programmatically and when it’s added again after being removed I want to still listening the events, otherwise after the Lifecycle.Event.ON_DESTROY the custom view stops receiving the view model events. I’ll try to use the activity as lifecycleOwner = . The weird thing is that the custom view is declared inside of the activity and has the same life cycle scope in theory.
skydoves commented Oct 7, 2020
Hi, @epool!
Could you let me know about this issue going on?
znakeeye commented Oct 16, 2020
This could happen if you show a tooltip in some event handler where the event is handled just after e.g. user has pressed the back button.
I tried safe-guarding by checking fragment.isAdded() and possibly also (don’t remember) fragment.isRemoving() but it still crashed. My fix was to skip the tooltip entirely.
For sure, we need some extra checks when showing the balloon. Will try to isolate this in a sample project at some point. Did the OP solve this?
sembozdemir commented Oct 19, 2020
This issue is also happening for my app. Stacktrace is the same. I use it in an activity. I also use LiveData.
skydoves commented Nov 7, 2020
@znakeeye @sembozdemir
I released a new version 1.2.5.
This update includes preventing to show popups in activities when the window is already detached from the activities.
Please let me know if the same crash continues. Thanks!
znakeeye commented Nov 10, 2020
@skydoves @sembozdemir
So far, I have not been able to reproduce this error in my setup. Very encouraging! Would be great if someone could confirm the fix in a published app.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Источник