Closed Hospes closed 1 year ago
Hi @Hospes 👋 It seems like LocalSoftwareKeyboardController
is being removed in the alpha version of Compose UI 1.6.0. Therefore, you’re seeing the ClassNotFoundException
.
Are you able to downgrade to a non-alpha version of Compose Material3? It seems like version 1.1.1 doesn’t depend on the alpha version of Compose UI.
Once Compose UI 1.6.0 is stable, we’ll be looking to upgrade ourselves and address the issue then.
Thank you for your answer. Well reverting back to material2 gonna be not an easy task, but we don't have any other options. So will do it.
I don’t think you’ll need to downgrade from Material 3 to Material 2. It looks to me like version 1.1.1 of Material 3 doesn’t depend on any alpha versions, so that should be good enough.
I’m going to close this issue now, but feel free to reach out with any other issues you encounter.
This is a blocker for our integration of Stripe while migrating away from Braintree in our org.
We use LocalSoftwareKeyboardController
within our code to dismiss the software keyboard in Material 3, so I feel like this could be a red herring.
Hi David 👋 We can’t depend on Compose 1.6.0 just yet, as it’s an alpha version.
A temporary workaround could be for you to use LocalTextInputService
instead of LocalSoftwareKeyboardController
. That’s what the latter uses internally (despite its method being marked as deprecated).
Is that feasible for you?
I don't think so... We heavily depend on Material 3 alpha at the moment due to its DatePicker composable, etc.
Would there be any issues with locally modifying the library to depend on 1.6.0-alpha? Or potentially an alpha version of the SDK to match? I get this isn't ideal for anyone, though.
is it possible to exclude compose dependencies by exclude(group = "com.stripe", module = "paymentsheet")?
Hi David 👋 We can’t depend on Compose 1.6.0 just yet, as it’s an alpha version.
A temporary workaround could be for you to use
LocalTextInputService
instead ofLocalSoftwareKeyboardController
. That’s what the latter uses internally (despite its method being marked as deprecated).Is that feasible for you?
Looking back at this again this week, I don't really understand what's causing this issue.
Stripe uses LocalSoftwareKeyboardController
in its SDK code, and so do we within our code.
LocalSoftwareKeyboardController
hasn't been removed in Compose 1.6.0-alpha (else obviously we couldn't be using it in our app which depends on this).
I think there's some other issue I'm missing here.
The problem here is that Stripe Android SDK is calling an ExperimentalComposeUiApi
API, which is subject to change.
LocalSoftwareKeyboardController
changed in compose.ui
1.6.0-alpha02
See here: https://android-review.googlesource.com/c/platform/frameworks/support/+/2628449
In Compose 1.5.x
it was:
@ExperimentalComposeUiApi
public object LocalSoftwareKeyboardController {
After 1.6.0-alpha02
it is this:
val LocalSoftwareKeyboardController = staticCompositionLocalOf<SoftwareKeyboardController?> { null }
Compose made a binary incompatible change, which is to be expected for anything marked with @ExperimentalComposeUiApi
.
Ideally, the Stripe SDK would not use any @OptIn
APIs from it's dependencies, as it will create binary compatibility problems.
One possible workaround for apps that are facing this issue:
in app/src/main/kotlin/androidx/compose/ui/platform/LocalSoftwareKeyboardController.kt
put this bridge:
package androidx.compose.ui.platform
import androidx.compose.runtime.Composable
// Used by Stripe Android SDK
// Work around for https://github.com/stripe/stripe-android/issues/7184
// This existed as Experimental in Compose 1.5, but was moved to a val in in Compose 1.6
@Suppress("unused")
object LocalSoftwareKeyboardController {
val current
@Composable
get() = LocalSoftwareKeyboardController.current
}
Thanks for posting the workaround here, @yogurtearl 🙏 And you’re right, I should have been more careful around using this experimental API. The team and I will be more conscious of this going forward.
Just for the next developer who comes along as lost as I was:
Step 1: Create a path in your project -> app/src/main/kotlin/androidx/compose/ui/platform (For me I had to create "/kotlin/androidx/compose/ui/platform"
Step 2: Create the LocalSoftwareKeyboardController class in that directory and copy the above code into it.
Step 3: You did it! Have a drink and stop hitting your head on the table.
Presumably no longer an issue after #7840 is merged and released 🙏
Hi @Hospes 👋 It seems like
LocalSoftwareKeyboardController
is being removed in the alpha version of Compose UI 1.6.0. Therefore, you’re seeing theClassNotFoundException
.Are you able to downgrade to a non-alpha version of Compose Material3? It seems like version 1.1.1 doesn’t depend on the alpha version of Compose UI.
Once Compose UI 1.6.0 is stable, we’ll be looking to upgrade ourselves and address the issue then.
Last working Compose UI version I tried within the 1.5.x span is
implementation 'androidx.compose.ui:ui-android:1.5.4'
Summary
Stripe crashes on rememberPaymentSheet.launch(). I'm using android compose 1.6.0-alpha03. If I'm switching back to version 1.5.0 it's working fine. So the problem only with new version. But unfortunately new material3 forces all dependencies to 1.6.0-alpha03 so we can't downgrade android compose. Is it possible to provide hotfix or stripe-android alpha build with supporting newest android compose ?
Code to reproduce
Just launch StripeSheet activity with android compose dependency version 1.6.0-alpha03
Android version
Android 13
Impacted devices
OnePlus 10Pro
Installation method
gradle implementation("com.stripe:stripe-android:20.28.2")
Dependency Versions
kotlin: 1.9.0 stripe-android: 20.28.2 Android Gradle Plugin: 8.1.0 Gradle: 8.3
SDK classes
PaymentSheetScreen
Other information
Here is error stacktrace: