Status Update
Comments
g....@cmcmarkets.com <g....@cmcmarkets.com> #2
as...@google.com <as...@google.com>
so...@google.com <so...@google.com> #3
Setting as P1 as this reported as a regression in 1.7.0.
so...@google.com <so...@google.com> #4
Ralston, could you please have a look or help find the owner? It looks like a focus issue
g....@cmcmarkets.com <g....@cmcmarkets.com> #5
ke...@bandlab.com <ke...@bandlab.com> #6
g....@cmcmarkets.com <g....@cmcmarkets.com> #7
se...@google.com <se...@google.com>
mo...@google.com <mo...@google.com> #8
I am able to repro on tip-of-tree
g....@cmcmarkets.com <g....@cmcmarkets.com> #10
al...@airbnb.com <al...@airbnb.com> #11
Just FYI, we're also seeing a different stacktrace that is being grouped together with the one above, which also originates in AndroidComposeView
. Is this also fixed by
java.lang.IllegalStateException: Event can't be processed because we do not have an active focus target.
at androidx.compose.ui.focus.FocusOwnerImpl.dispatchKeyEvent-ZmokQxo(FocusOwnerImpl:206)
at androidx.compose.ui.platform.AndroidComposeView.dispatchKeyEvent(AndroidComposeView:696)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1965)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1965)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1965)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1965)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1965)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1965)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1965)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1965)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1965)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1965)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1965)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1965)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1965)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1965)
at com.android.internal.policy.DecorView.superDispatchKeyEvent(DecorView.java:476)
at com.android.internal.policy.PhoneWindow.superDispatchKeyEvent(PhoneWindow.java:1861)
at android.app.Activity.dispatchKeyEvent(Activity.java:4085)
at androidx.core.app.ComponentActivity.superDispatchKeyEvent(ComponentActivity:120)
at androidx.core.app.ComponentActivity.superDispatchKeyEvent(ComponentActivity:120)
at androidx.core.view.KeyEventDispatcher.dispatchKeyEvent(KeyEventDispatcher:85)
at androidx.core.app.ComponentActivity.dispatchKeyEvent(ComponentActivity:138)
at androidx.appcompat.app.AppCompatActivity.dispatchKeyEvent(AppCompatActivity:604)
at androidx.appcompat.view.WindowCallbackWrapper.dispatchKeyEvent(WindowCallbackWrapper:60)
at androidx.appcompat.app.AppCompatDelegateImpl$AppCompatWindowCallback.dispatchKeyEvent(AppCompatDelegateImpl:3413)
at com.airbnb.android.lib.cobrowse.sdk.DelegatingWindowCallback.dispatchKeyEvent(DelegatingWindowCallback:130)
at com.android.internal.policy.DecorView.dispatchKeyEvent(DecorView.java:390)
at android.view.ViewRootImpl$ViewPostImeInputStage.processKeyEvent(ViewRootImpl.java:6105)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:5968)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:5459)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:5516)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:5482)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:5634)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:5490)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:5691)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:5463)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:5516)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:5482)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:5490)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:5463)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:5516)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:5482)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:5667)
at android.view.ViewRootImpl$ImeInputStage.onFinishedInputEvent(ViewRootImpl.java:5829)
at android.view.inputmethod.InputMethodManager$PendingEvent.run(InputMethodManager.java:3179)
at android.view.inputmethod.InputMethodManager.invokeFinishedInputEventCallback(InputMethodManager.java:2721)
at android.view.inputmethod.InputMethodManager.finishedInputEvent(InputMethodManager.java:2712)
at android.view.inputmethod.InputMethodManager$ImeInputEventSender.onInputEventFinished(InputMethodManager.java:3156)
at android.view.InputEventSender.dispatchInputEventFinished(InputEventSender.java:143)
at android.os.MessageQueue.nativePollOnce(MessageQueue.java:-2)
at android.os.MessageQueue.next(MessageQueue.java:335)
at android.os.Looper.loop(Looper.java:183)
at android.app.ActivityThread.main(ActivityThread.java:7723)
at java.lang.reflect.Method.invoke(Method.java:-2)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:612)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:997)
si...@empiriecom.com <si...@empiriecom.com> #12
So I think with 1.7.3 version of the androidx.compose.ui package.
g....@cmcmarkets.com <g....@cmcmarkets.com> #13
ke...@bandlab.com <ke...@bandlab.com> #14
g....@cmcmarkets.com <g....@cmcmarkets.com> #15
mo...@google.com <mo...@google.com> #16
Can you attach a sample project that reproduces it? I may have fixed one bug, but there could have been another one.
mo...@google.com <mo...@google.com> #17
I just verified that my test app works on 1.7.3, but not on 1.7.2, so I did fix this specific bug. Please file a new bug for the failure and how to reproduce it.
g....@cmcmarkets.com <g....@cmcmarkets.com> #18
Hiya, strange that. My test app still crashes with the exact same steps and give the exact same error for the compose ui versions above 1.6.8.
Here is the code sample that crashes, I hope it helps: layout: main.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<EditText
android:id="@+id/edit_text"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_marginTop="100dp"
android:imeOptions="actionNext"
android:inputType="numberDecimal"/>
<androidx.compose.ui.platform.ComposeView
android:id="@+id/compose_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
And the activity:
class FocusCrashActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.main)
val composeView = findViewById<ComposeView>(R.id.compose_view)
composeView.setContent {
Greeting(
name = "Android",
modifier = Modifier.fillMaxSize()
)
}
}
}
@Composable
fun Greeting(name: String, modifier: Modifier = Modifier) {
Column(modifier = modifier
.fillMaxSize()
.background(Color.Blue)) {
}
}
gradle file:
plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.jetbrains.kotlin.android)
}
android {
namespace = "com.example.myapplication"
compileSdk = 35
defaultConfig {
applicationId = "com.example.myapplication"
minSdk = 24
targetSdk = 35
versionCode = 1
versionName = "1.0"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary = true
}
}
buildTypes {
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
buildFeatures {
compose = true
}
composeOptions {
kotlinCompilerExtensionVersion = "1.5.1"
}
packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}
}
dependencies {
implementation(libs.androidx.core.ktx)
implementation(libs.androidx.lifecycle.runtime.ktx)
implementation(libs.androidx.activity.compose)
implementation(libs.androidx.ui)
implementation(libs.androidx.compose.foundation)
testImplementation(libs.junit)
}
g....@cmcmarkets.com <g....@cmcmarkets.com> #19
With further testing, I can see why we have different results. It is because I get different results for these scenarios:
1 - The code above, where Column
has no children: Ui v1.6.8: Works, Ui v1.7.5: Crashes
2 - If I put a TextField
in the Column: Ui v1.6.8: Works, Ui v1.7.5: Works
3 - If I put a Text
in the Column: Ui v1.6.8 Material3 v1.2.1 (same BOM): Works, Ui v1.7.5: Crashes
PS: The 3rd option crashes too with Ui:1.6.8 and Material3: 1.3.1
Currently only it doesn't crash with a TextField
as far as I can see in with 1.7.5, I don't think the fix addresses the initial ticket opened, e.g., where there is a Text
in compose view
g....@cmcmarkets.com <g....@cmcmarkets.com> #20
Opened a new issue as developer suggested:
ta...@gotinder.com <ta...@gotinder.com> #21
Related to
Description
Jetpack Compose component(s) used: ComposeView
Android Studio Build: #AI-241.18034.62.2411.12169540 (Android Studio Koala | 2024.1.1 Patch 2)
Kotlin version: 1.9.0
Steps to Reproduce or Code Sample to Reproduce:
1. Create project with an activity with an xml layout that has a vertical LinerLayout parent view group
2. In linear layout, create an EditText with android:imeOptions="actionNext" and android:inputType="numberDecimal"
3. Again in linear layout, under the EditText, create a ComposeView (v 1.7.0-beta04)
4. In the activity, set content of the ComposeView, e.g. a composable Text
5. Run the app and tap on the EditText to show keypad
6. In the keypad, tap next button to focus on the AndroidComposeView that is created by compose
7. App crashes because AndroidComposeView that is found by onEditorAction is not focusable
8. It doesn't crash in stable version of ComposeView v1.6.8
Stack trace (if applicable):
```
FATAL EXCEPTION: main (Ask Gemini)
Process: com.example.myapplication, PID: 16396
java.lang.IllegalStateException: focus search returned a view that wasn't able to take focus!
at android.widget.TextView.onEditorAction(TextView.java:7420)
at com.android.internal.inputmethod.EditableInputConnection.performEditorAction(EditableInputConnection.java:156)
at com.android.internal.inputmethod.RemoteInputConnectionImpl.lambda$performEditorAction$21$com-android-internal-inputmethod-RemoteInputConnectionImpl(RemoteInputConnectionImpl.java:654)
at com.android.internal.inputmethod.RemoteInputConnectionImpl$$ExternalSyntheticLambda33.run(Unknown Source:6)
at android.os.Handler.handleCallback(Handler.java:942)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7872)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
```