Compose桌面应用鼠标滚动触发ACTION_HOVER_EXIT未清除崩溃求助
桌面端Android应用鼠标滚动崩溃:ACTION_HOVER_EXIT未清除异常
我偶尔会在桌面端使用自研的Android应用,但无论在应用内任何区域(可滚动或不可滚动)使用鼠标滚动,应用都会崩溃,抛出异常:
java.lang.IllegalStateException: The ACTION_HOVER_EXIT event was not cleared.
经排查,崩溃的根源来自Compose UI库内部的以下代码逻辑:
/** * If an [ACTION_HOVER_EXIT] event is received, it could be because an [ACTION_DOWN] is coming * from a mouse or stylus. We can't know for certain until the next event is sent. This message * is posted after receiving the [ACTION_HOVER_EXIT] to send the event if nothing else is * received before that. */ private val sendHoverExitEvent = Runnable { hoverExitReceived = false val lastEvent = previousMotionEvent!! check(lastEvent.actionMasked == ACTION_HOVER_EXIT) { "The ACTION_HOVER_EXIT event was not cleared." } sendMotionEvent(lastEvent) }
我并未在代码中显式声明dispatchHoverEvent或dispatchTouchEvent方法,而上述Runnable正是在这类事件分发方法中被调用的。
我正在寻求任何解决方案(临时或永久均可),同时想了解:
- 是否有其他用户遇到过相同问题
- 这是否是特定Compose库版本导致的问题
更新:我的项目依赖配置如下:
androidx.compose:compose-bom:2023.10.01 androidx.activity:activity-compose:1.8.1 androidx.lifecycle:lifecycle-viewmodel-compose:2.6.2 androidx.compose.foundation:foundation:1.5.4 androidx.hilt:hilt-navigation-compose:1.1.0 androidx.navigation:navigation-compose:2.7.5 com.google.dagger:hilt-compiler:2.46.1 com.google.dagger:hilt-android:2.48
内容的提问来源于stack exchange,提问作者Jakub Kostka
相关产品推荐
相关产品推荐

