-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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: focus search returned a view that wasn't able to take focus! #21563
Comments
Thanks for reporting! 👍 |
Looking at the crash reports, the problem occurs in SiteCreationActivity, but it may also occur in:
|
From Gemini: Summary The app crashed because a TextView failed to take focus when the focus search mechanism tried to give it focus during a key up event. This happened inside an onKeyUp method of a TextView. The stack trace shows that the key event traveled through a complex view hierarchy, including a NestedScrollView, before reaching the problematic TextView. The presence of NestedScrollView suggests that there might be scrollable content involved. This crash is an IllegalStateException, which indicates an unexpected internal state within the Android framework. Potential Solutions Check focusable and focusableInTouchMode attributes: The most likely cause is that the TextView which the focus search landed on was not actually focusable. Ensure that the TextView in question has both the android:focusable="true" and android:focusableInTouchMode="true" attributes set in its XML layout or programmatically. focusableInTouchMode is particularly important if the user is interacting with the UI using touch.
Alternatively, ensure these are set programmatically:
Inspect Focus Handling Logic within NestedScrollView: The presence of androidx.core.widget.NestedScrollView in the stack trace suggests potential issues with focus handling within scrollable content. Verify that the layout within the NestedScrollView is set up correctly to manage focus transitions, especially when items are scrolled on or off-screen. Pay attention to any custom focus handling logic you might have implemented. You may want to look for potential calls to requestFocus() or overrides of onKeyUp, onKeyDown, or dispatchKeyEvent to see if your code interferes with the normal process of determining focus. If there is custom focus handling, validate that the code correctly accounts for all possible view states and always returns a focusable view when calling requestFocus(). Review Key Event Handling: Although less likely, an issue with your custom key event handling could be contributing to the problem. If you have overridden methods like onKeyUp, onKeyDown, or dispatchKeyEvent in any of your Activities, Fragments, or custom Views, particularly those within or related to the NestedScrollView, double-check the logic within these methods. Make sure that your handling doesn't interfere with the standard Android focus mechanisms. If your custom handling returns true when an event is not fully processed, it can short-circuit the normal focus search and lead to this type of error. Consider removing custom handling if not absolutely necessary. |
I was finally able to reproduce this crash. It's happening in our domain registration fragment:
crash.mp4 |
Closed via #21566 |
Sentry Issue: JETPACK-ANDROID-12YC
The text was updated successfully, but these errors were encountered: