Skip to content

[Authenticator] NoSuchMethodError: rememberModalBottomSheetState #221

@mattcreaser

Description

@mattcreaser

Before creating a new issue, please confirm:

Which UI component?

Authenticator

Gradle script dependencies

compose-bom = "2025.02.00"
authenticator = "1.4.2"

Environment information

n/a

Please include any relevant guides or documentation you're referencing

No response

Describe the bug

When using newer versions of Compose (e.g. BOM 2025.02.00) and Authenticator 1.4.2, if the create account is configured to use a phone number field and user attempts to change the country code Authenticator will crash:

java.lang.NoSuchMethodError: No static method rememberModalBottomSheetState(ZLkotlin/jvm/functions/Function1;Landroidx/compose/runtime/Composer;II)Landroidx/compose/material3/SheetState; in class Landroidx/compose/material3/ModalBottomSheet_androidKt; or its super classes (declaration of 'androidx.compose.material3.ModalBottomSheet_androidKt' appears in /data/app/com.amplify.testapps-SB10WduC1MsrvzO2A_7ahQ==/base.apk)
                                                                                                    	at com.amplifyframework.ui.authenticator.ui.PhoneInputFieldKt.DialCodeSelector(PhoneInputField.kt:152)
                                                                                                    	at com.amplifyframework.ui.authenticator.ui.PhoneInputFieldKt.access$DialCodeSelector(PhoneInputField.kt:1)
                                                                                                    	at com.amplifyframework.ui.authenticator.ui.PhoneInputFieldKt$DialCodeSelector$4.invoke(Unknown Source:10)
                                                                                                    	at com.amplifyframework.ui.authenticator.ui.PhoneInputFieldKt$DialCodeSelector$4.invoke(Unknown Source:10)
                                                                                                    	at androidx.compose.runtime.RecomposeScopeImpl.compose(RecomposeScopeImpl.kt:192)
...

This happens because of binary incompatibilities between versions of the material3 library. Specifically, the ModalBottomSheet functions were moved from ModalBottomSheet.android.kt to ModalBottomSheet.kt in material3 1.3.0, changing the class name. I verified the crash does not occur if Authenticator is recompiled with material3 1.3.1

Reproduction steps (if applicable)

  1. Set app to use compose BOM 2025.02.00 or newer (did not test older versions)
  2. Configure Authenticator to show a phone number field on the create account page
  3. Run the app
  4. Try to click on the country code in the form

Code Snippet

val authenticatorState = rememberAuthenticatorState(
    signUpForm = {
        email()
        password()
        confirmPassword()
        phoneNumber()
        nickname()
    }
)

  Authenticator(
      state = authenticatorState,
      modifier = Modifier.padding(top = 16.dp)
  ) { signedInState ->
      // ...
  }

Log output

2025-04-01 12:26:16.032   854-854   AndroidRuntime          com.amplify.testapps                 E  FATAL EXCEPTION: main
                                                                                                    Process: com.amplify.testapps, PID: 854
                                                                                                    java.lang.NoSuchMethodError: No static method rememberModalBottomSheetState(ZLkotlin/jvm/functions/Function1;Landroidx/compose/runtime/Composer;II)Landroidx/compose/material3/SheetState; in class Landroidx/compose/material3/ModalBottomSheet_androidKt; or its super classes (declaration of 'androidx.compose.material3.ModalBottomSheet_androidKt' appears in /data/app/com.amplify.testapps-ELm8qnmFtVHwkxqQaLLauQ==/base.apk)
                                                                                                    	at com.amplifyframework.ui.authenticator.ui.PhoneInputFieldKt.DialCodeSelector(PhoneInputField.kt:152)
                                                                                                    	at com.amplifyframework.ui.authenticator.ui.PhoneInputFieldKt.access$DialCodeSelector(PhoneInputField.kt:1)
                                                                                                    	at com.amplifyframework.ui.authenticator.ui.PhoneInputFieldKt$DialCodeSelector$4.invoke(Unknown Source:10)
                                                                                                    	at com.amplifyframework.ui.authenticator.ui.PhoneInputFieldKt$DialCodeSelector$4.invoke(Unknown Source:10)
                                                                                                    	at androidx.compose.runtime.RecomposeScopeImpl.compose(RecomposeScopeImpl.kt:192)
                                                                                                    	at androidx.compose.runtime.ComposerImpl.recomposeToGroupEnd(Composer.kt:2825)
                                                                                                    	at androidx.compose.runtime.ComposerImpl.skipCurrentGroup(Composer.kt:3116)
                                                                                                    	at androidx.compose.runtime.ComposerImpl.doCompose(Composer.kt:3607)
                                                                                                    	at androidx.compose.runtime.ComposerImpl.recompose$runtime_release(Composer.kt:3552)
                                                                                                    	at androidx.compose.runtime.CompositionImpl.recompose(Composition.kt:948)
                                                                                                    	at androidx.compose.runtime.Recomposer.performRecompose(Recomposer.kt:1206)
                                                                                                    	at androidx.compose.runtime.Recomposer.access$performRecompose(Recomposer.kt:132)
                                                                                                    	at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2$1.invoke(Recomposer.kt:616)
                                                                                                    	at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2$1.invoke(Recomposer.kt:585)
                                                                                                    	at androidx.compose.ui.platform.AndroidUiFrameClock$withFrameNanos$2$callback$1.doFrame(AndroidUiFrameClock.android.kt:41)
                                                                                                    	at androidx.compose.ui.platform.AndroidUiDispatcher.performFrameDispatch(AndroidUiDispatcher.android.kt:109)
                                                                                                    	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:909)
                                                                                                    	at android.view.Choreographer.doCallbacks(Choreographer.java:723)
                                                                                                    	at android.view.Choreographer.doFrame(Choreographer.java:655)
                                                                                                    	at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:897)
                                                                                                    	at android.os.Handler.handleCallback(Handler.java:789)
                                                                                                    	at android.os.Handler.dispatchMessage(Handler.java:98)
                                                                                                    	at android.os.Looper.loop(Looper.java:164)
                                                                                                    	at android.app.ActivityThread.main(ActivityThread.java:6541)
                                                                                                    	at java.lang.reflect.Method.invoke(Native Method)
                                                                                                    	at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
                                                                                                    	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)

amplifyconfiguration.json

No response

Additional information and screenshots

No response

Metadata

Metadata

Assignees

Labels

authenticatorThis issue relates to the Authenticator componentbugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions