I've added the <M3 SearchBar component> to my proj...
# compose-android
m
I've added the M3 SearchBar component to my project. When entering a screen with the
SearchBar
component I get the following crash:
Copy code
java.lang.NoSuchMethodError: No static method SearchBar-Y92LkZI(Lkotlin/jvm/functions/Function2;ZLkotlin/jvm/functions/Function1;Landroidx/compose/ui/Modifier;Landroidx/compose/ui/graphics/Shape;Landroidx/compose/material3/SearchBarColors;FFLandroidx/compose/foundation/layout/WindowInsets;Lkotlin/jvm/functions/Function3;Landroidx/compose/runtime/Composer;II)V in class Landroi
I've got no issues with other M3 components I've tried. Running Compose BOM
2025.05.01
, nav3, M3 adaptive. I've tried to look for this in the IssueTracker, but no luck there. Any suggestions?
s
The signature is correct, what is the full stack trace?
m
Here we go with the full trace, package / screen names changed.
Copy code
FATAL EXCEPTION: main
Process: com.myprocess.debug, PID: 2298
java.lang.NoSuchMethodError: No static method SearchBar-Y92LkZI(Lkotlin/jvm/functions/Function2;ZLkotlin/jvm/functions/Function1;Landroidx/compose/ui/Modifier;Landroidx/compose/ui/graphics/Shape;Landroidx/compose/material3/SearchBarColors;FFLandroidx/compose/foundation/layout/WindowInsets;Lkotlin/jvm/functions/Fun
	at MyScreen(MyScreen.kt:52)
	at MyScreen(MyScreen.kt:34)
	at MyScreen$2$1.invoke(MyScreen.kt:82)
	at MyScreen$MyScreen$2$1.invoke(MyScreen.kt:79)
	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.kt:130)
	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke$lambda$0(ComposableLambda.kt:132)
	at androidx.compose.runtime.internal.ComposableLambdaImpl.$r8$lambda$qz3voikrQeNn5XJEtUlXR2wfzBw(Unknown Source:0)
	at androidx.compose.runtime.internal.ComposableLambdaImpl$$ExternalSyntheticLambda16.invoke(D8$$SyntheticClass:0)
	at androidx.compose.runtime.RecomposeScopeImpl.compose(RecomposeScopeImpl.kt:214)
	at androidx.compose.runtime.ComposerImpl.recomposeToGroupEnd(Composer.kt:2898)
	at androidx.compose.runtime.ComposerImpl.skipToGroupEnd(Composer.kt:3282)
	at androidx.compose.material3.adaptive.layout.PaneKt.AnimatedPane(Pane.kt:69)
	at MyScreen$2.invoke(MyScreen.kt:77)
	at MyScreen$2.invoke(MyScreen.kt:76)
	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.kt:130)
	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke$lambda$0(ComposableLambda.kt:132)
	at androidx.compose.runtime.internal.ComposableLambdaImpl.$r8$lambda$qz3voikrQeNn5XJEtUlXR2wfzBw(Unknown Source:0)
	at androidx.compose.runtime.internal.ComposableLambdaImpl$$ExternalSyntheticLambda16.invoke(D8$$SyntheticClass:0)
	at androidx.compose.runtime.RecomposeScopeImpl.compose(RecomposeScopeImpl.kt:214)
	at androidx.compose.runtime.ComposerImpl.recomposeToGroupEnd(Composer.kt:2898)
	at androidx.compose.runtime.ComposerImpl.skipToGroupEnd(Composer.kt:3282)
	at androidx.compose.material3.adaptive.navigation.AndroidThreePaneScaffold_androidKt.NavigableListDetailPaneScaffold-E_5xQPI(AndroidThreePaneScaffold.android.kt:80)
	at MyScreen.MyScreen(MyScreen.kt:42)
	at MyScreen$1(Unknown Source:6)
	at MyScreen.$r8$lambda$fyhSO73WQoJPRPwt5IKEwZMI86w(Unknown Source:0)
	at MyScreen$$ExternalSyntheticLambda0.invoke(D8$$SyntheticClass:0)
	at androidx.compose.runtime.RecomposeScopeImpl.compose(RecomposeScopeImpl.kt:214)
	at androidx.compose.runtime.ComposerImpl.recomposeToGroupEnd(Composer.kt:2898)
	at androidx.compose.runtime.ComposerImpl.skipCurrentGroup(Composer.kt:3224)
	at androidx.compose.runtime.ComposerImpl.doCompose-aFTiNEg(Composer.kt:3820)
	at androidx.compose.runtime.ComposerImpl.recompose-aFTiNEg$runtime_release(Composer.kt:3762)
	at androidx.compose.runtime.CompositionImpl.recompose(Composition.kt:1014)
	at androidx.compose.runtime.Recomposer.performRecompose(Recomposer.kt:1304)
	at androidx.compose.runtime.Recomposer.access$performRecompose(Recomposer.kt:144)
	at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2.invokeSuspend$lambda$22(Recomposer.kt:623)
	at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2.$r8$lambda$OqADLCDYmRw1RgNUvn1CR0kX32M(Unknown Source:0)
	at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2$$ExternalSyntheticLambda0.invoke(D8$$SyntheticClass:0)
	at androidx.compose.ui.platform.AndroidUiFrameClock$withFrameNanos$2$callback$1.doFrame(AndroidUiFrameClock.android.kt:39)
	at androidx.compose.ui.platform.AndroidUiDispatcher.performFrameDispatch(AndroidUiDispatcher.android.kt:108)
	at androidx.compose.ui.platform.AndroidUiDispatcher.access$performFrameDispatch(AndroidUiDispatcher.android.kt:41)
	at androidx.compose.ui.platform.AndroidUiDispatcher$dispatchCallback$1.doFrame(AndroidUiDispatcher.android.kt:69)
	at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1749)
	at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1760)
	at android.view.Choreographer.doCallbacks(Choreographer.java:1216)
	at android.view.Choreographer.doFrame(Choreographer.java:1132)
	at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1707)
	at android.os.Handler.handleCallback(Handler.java:959)
	at android.os.Handler.dispatchMessage(Handler.java:100)
	at android.os.Looper.loopOnce(Looper.java:257)
	at android.os.Looper.loop(Looper.java:342)
	at android.app.ActivityThread.main(ActivityThread.java:9638)

                                                                                                    	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:619)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:929)
	Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [androidx.compose.runtime.PausableMonotonicFrameClock@84109bf, androidx.compose.ui.platform.MotionDurationScaleImpl@d63888c, StandaloneCoroutine{Cancelling}@f43fbd5, AndroidUiDispatcher@26b4fea]
I tried bumping Compose related deps, but ran into this: https://issuetracker.google.com/issues/419049149. I switched over to
SNAPSHOT
deps for
compose-runtime-saveable
but ended up with the above crash again 🤷
s
yeah, that looks correct, and it fails when you call it directly unless you have the runtime / compile classpath diverging, I am not sure what's happening here
m
Any suggestions on figuring this one out? Like I mentioned, other M3 components seem to work great.
s
I would inspect the material3 dep, maybe this particular version is broken or something You can use decompilers such as jadx-gui to just drop the aar in and check what signature it has
👍 1
m
Gotcha, thanks! I'll see about it tomorrow!
Ok, so new findings: • Compose BOM
2025.05.01
maps to
material3
version
1.3.2
material3-android\1.3.2\e0404061e34ecbf250e37af2f6a619574b2cc86e
file
material3-release.aar
has:
Copy code
/* renamed from: SearchBar-Y92LkZI, reason: not valid java name */
public static final void m1089SearchBarY92LkZI
The actual method signature looks like the one I'm calling, but just to be safe I also added all the optional params, still crashes. So, confirming it's there I tried the following, but didn't help: • Invalidated caches & restart • Debug build (no R8/minimization/proguard) I tried adding the sample
SearchBar
to latest NIA (
8092c60c
) and it works without issue. I copy pasted the exact same code to my project: • Preview works (why...?) • Running the app results in the same crash as above I then tried setting up my project similarly to NIA: •
compose-bom-alpha
instead of stable with version
2025.02.00
This now works and doesn't crash, but it hardly makes sense to jump back to an old Compose BOM alpha mapping. Just switching
compose-bom
to
2025.02.00
doesn't solve the issue. Any suggestions on how to go forward with this?
Here's the sample code I'm referring to (pretty much the same as the sample shown in the KDocs:
Copy code
@OptIn(ExperimentalMaterial3Api::class)
@Composable
private fun CustomSearchBar() {
    var text by rememberSaveable { mutableStateOf("") }
    var expanded = false
    SearchBar(
        inputField = {
            SearchBarDefaults.InputField(
                query = text,
                onQueryChange = { text = it },
                onSearch = { expanded = false },
                expanded = expanded,
                onExpandedChange = { expanded = it },
                placeholder = { Text("Hinted search text") },
            )
        },
        expanded = expanded,
        onExpandedChange = { expanded = it },
    ) {
        Column(Modifier.verticalScroll(rememberScrollState())) {
            repeat(4) { idx ->
                val resultText = "Suggestion $idx"
                ListItem(
                    headlineContent = { Text(resultText) },
                    supportingContent = { Text("Additional info") },
                    colors = ListItemDefaults.colors(containerColor = Color.Transparent),
                    modifier =
                        Modifier.clickable {
                            text = resultText
                            expanded = false
                        }
                            .fillMaxWidth()
                            .padding(horizontal = 16.dp, vertical = 4.dp)
                )
            }
        }
    }

    LazyColumn(
        contentPadding = PaddingValues(start = 16.dp, top = 72.dp, end = 16.dp, bottom = 16.dp),
        verticalArrangement = Arrangement.spacedBy(8.dp),
        modifier = Modifier.semantics { traversalIndex = 1f },
    ) {
        val list = List(100) { "Text $it" }
        items(count = list.size) {
            Text(
                text = list[it],
                modifier = Modifier.fillMaxWidth().padding(horizontal = 16.dp),
            )
        }
    }
}
I built a debug .aab of my project, there I can find
method public static final SearchBar-Y92LkZI
in my
classes.dex
but it's under
SearchBarKt
not
SearchBar_androidKt
. I don't see the same
*_androidKt
naming when looking at the other
androix.compose.material3
classes that works as expected.
I specified a version for the M3 dep instead of using the BOM version:
Copy code
androidx-material3 = { group = "androidx.compose.material3", name = "material3", version.ref = "material3" }
And with that also added the
material-icons-extended
. That then fixed my issue, but I'd still prefer to use the BOM version. Is there somehting for me to do I'd prefer to use the BOM version, though. Any tips on that? E: So, my issue is with Material3
1.3.2
. The Compose BOM still refers to that version as it's the most recent stable version. Using M3
1.4.0.-alpha/beta
versions fix my issue. So I guess M3
1.4.0
will be used in the Compose BOM once it's stable and then I can switch back.
Well, looks like I celebrated too soon as now every
ModalBottomSheet
in the app crashes:
Copy code
FATAL EXCEPTION: main
 Process: com.myapp.debug, PID: 26346
 java.lang.UnsupportedOperationException: This function has a reified type parameter and thus can only be inlined at compilation time, not called directly.
 	at kotlin.jvm.internal.Intrinsics.throwUndefinedForReified(Intrinsics.java:209)
 	at kotlin.jvm.internal.Intrinsics.throwUndefinedForReified(Intrinsics.java:203)
 	at kotlin.jvm.internal.Intrinsics.needClassReification(Intrinsics.java:221)
 	at androidx.compose.runtime.saveable.RememberSaveableKt.rememberSaveable(RememberSaveable.kt:141)
 	at androidx.compose.material3.ModalBottomSheet_androidKt.ModalBottomSheetDialog-sW7UJKQ(ModalBottomSheet.android.kt:376)
 	at androidx.compose.material3.ModalBottomSheetKt.ModalBottomSheet-YbuCTN8(ModalBottomSheet.kt:170)
 	at com.myapp.ScreenContent(TransportListsScreen.kt:263)
 	at com.myapp.ScreenContent$lambda$43(Unknown Source:54)
 	at com.myapp.ScreenKt.$r8$lambda$s8l0_DP8klgp9qGNd426sH7F0ns(Unknown Source:0)
 	at com.myapp.ScreenKt$$ExternalSyntheticLambda10.invoke(D8$$SyntheticClass:0)
 	at androidx.compose.runtime.RecomposeScopeImpl.compose(RecomposeScopeImpl.kt:214)
 	at androidx.compose.runtime.ComposerImpl.recomposeToGroupEnd(Composer.kt:2898)
 	at androidx.compose.runtime.ComposerImpl.skipCurrentGroup(Composer.kt:3224)
 	at androidx.compose.runtime.ComposerImpl.doCompose-aFTiNEg(Composer.kt:3820)
 	at androidx.compose.runtime.ComposerImpl.recompose-aFTiNEg$runtime_release(Composer.kt:3762)
 	at androidx.compose.runtime.CompositionImpl.recompose(Composition.kt:1014)
 	at androidx.compose.runtime.Recomposer.performRecompose(Recomposer.kt:1304)
 	at androidx.compose.runtime.Recomposer.access$performRecompose(Recomposer.kt:144)
 	at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2.invokeSuspend$lambda$22(Recomposer.kt:623)
 	at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2.$r8$lambda$OqADLCDYmRw1RgNUvn1CR0kX32M(Unknown Source:0)
 	at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2$$ExternalSyntheticLambda0.invoke(D8$$SyntheticClass:0)
 	at androidx.compose.ui.platform.AndroidUiFrameClock$withFrameNanos$2$callback$1.doFrame(AndroidUiFrameClock.android.kt:39)
 	at androidx.compose.ui.platform.AndroidUiDispatcher.performFrameDispatch(AndroidUiDispatcher.android.kt:108)
 	at androidx.compose.ui.platform.AndroidUiDispatcher.access$performFrameDispatch(AndroidUiDispatcher.android.kt:41)
 	at androidx.compose.ui.platform.AndroidUiDispatcher$dispatchCallback$1.doFrame(AndroidUiDispatcher.android.kt:69)
 	at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1749)
 	at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1760)
 	at android.view.Choreographer.doCallbacks(Choreographer.java:1216)
 	at android.view.Choreographer.doFrame(Choreographer.java:1132)
 	at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1707)
 	at android.os.Handler.handleCallback(Handler.java:959)
 	at android.os.Handler.dispatchMessage(Handler.java:100)
 	at android.os.Looper.loopOnce(Looper.java:257)
 	at android.os.Looper.loop(Looper.java:342)
 	at android.app.ActivityThread.main(ActivityThread.java:9638)
   at java.lang.reflect.Method.invoke(Native Method)
 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:619)
 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:929)
 	Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [androidx.compose.runtime.PausableMonotonicFrameClock@5613a97, androidx.compose.ui.platform.MotionDurationScaleImpl@20a2484, StandaloneCoroutine{Cancelling}@789f46d, AndroidUiDispatcher@78478a2]
Any thoughts on what could be wrong here?
Well, to answer my own question: • Decided to use a separate dependency for
runtime-saveable
• The above resulted in this one, again: https://issuetracker.google.com/issues/419049149 • I switched once more over to
1.10.0-SNAPSHOT
for the
runtime-saveable
and everything works now So, now I've dug myself into using a M3 beta version as well as a
runtime-saveable
SNAPSHOT...
s
I wonder if that's an incremental compilation issue or something of the build cache variety
m
We ended up copying the SearchBar implementation in the end, that was a straightforward workaround. We'll go back to the compose version again sometime in the future when we have time to figure out these dependency issues
👍🏿 1