flutter-stripe / flutter_stripe

Flutter SDK for Stripe.
https://pub.dev/packages/flutter_stripe
927 stars 511 forks source link

The Android app crashes when the payment sheet opens with the error: "java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/compose/ui/platform/LocalSoftwareKeyboardController." #1642

Open j-mary opened 6 months ago

j-mary commented 6 months ago

This was working fine recently, but suddenly started to crash. I was on version 9.6.0 when I noticed the crash. I updated to version 10.0.0 but still experienced the crash.

Log:

E/AndroidRuntime( 6733): FATAL EXCEPTION: main E/AndroidRuntime( 6733): java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/compose/ui/platform/LocalSoftwareKeyboardController; E/AndroidRuntime( 6733): at com.stripe.android.common.ui.BottomSheetKeyboardHandlerKt.rememberBottomSheetKeyboardHandler(BottomSheetKeyboardHandler.kt:38) E/AndroidRuntime( 6733): at com.stripe.android.common.ui.BottomSheetKt.rememberBottomSheetState(BottomSheet.kt:96) E/AndroidRuntime( 6733): at com.stripe.android.paymentsheet.PaymentSheetActivity$onCreate$2$1.invoke(PaymentSheetActivity.kt:65) E/AndroidRuntime( 6733): at com.stripe.android.paymentsheet.PaymentSheetActivity$onCreate$2$1.invoke(PaymentSheetActivity.kt:62) E/AndroidRuntime( 6733): at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:109) E/AndroidRuntime( 6733): at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35) E/AndroidRuntime( 6733): at androidx.compose.material.MaterialTheme_androidKt.PlatformMaterialTheme(MaterialTheme.android.kt:23) E/AndroidRuntime( 6733): at androidx.compose.material.MaterialThemeKt$MaterialTheme$1$1.invoke(MaterialTheme.kt:82) E/AndroidRuntime( 6733): at androidx.compose.material.MaterialThemeKt$MaterialTheme$1$1.invoke(MaterialTheme.kt:81) E/AndroidRuntime( 6733): at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:109) E/AndroidRuntime( 6733): at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35) E/AndroidRuntime( 6733): at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:248) E/AndroidRuntime( 6733): at androidx.compose.material.TextKt.ProvideTextStyle(Text.kt:396) E/AndroidRuntime( 6733): at androidx.compose.material.MaterialThemeKt$MaterialTheme$1.invoke(MaterialTheme.kt:81) E/AndroidRuntime( 6733): at androidx.compose.material.MaterialThemeKt$MaterialTheme$1.invoke(MaterialTheme.kt:80) E/AndroidRuntime( 6733): at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:109) E/AndroidRuntime( 6733): at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35) E/AndroidRuntime( 6733): at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:228) E/AndroidRuntime( 6733): at androidx.compose.material.MaterialThemeKt.MaterialTheme(MaterialTheme.kt:72) E/AndroidRuntime( 6733): at com.stripe.android.uicore.StripeThemeKt$StripeTheme$1.invoke(StripeTheme.kt:331) E/AndroidRuntime( 6733): at com.stripe.android.uicore.StripeThemeKt$StripeTheme$1.invoke(StripeTheme.kt:330) E/AndroidRuntime( 6733): at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:109) E/AndroidRuntime( 6733): at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35) E/AndroidRuntime( 6733): at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:228) E/AndroidRuntime( 6733): at com.stripe.android.uicore.StripeThemeKt.StripeTheme(StripeTheme.kt:325) E/AndroidRuntime( 6733): at com.stripe.android.paymentsheet.PaymentSheetActivity$onCreate$2.invoke(PaymentSheetActivity.kt:62) E/AndroidRuntime( 6733): at com.stripe.android.paymentsheet.PaymentSheetActivity$onCreate$2.invoke(PaymentSheetActivity.kt:61) E/AndroidRuntime( 6733): at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:109) E/AndroidRuntime( 6733): at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35) E/AndroidRuntime( 6733): at androidx.compose.ui.platform.ComposeView.Content(ComposeView.android.kt:428) E/AndroidRuntime( 6733): at androidx.compose.ui.platform.AbstractComposeView$ensureCompositionCreated$1.invoke(ComposeView.android.kt:252) E/AndroidRuntime( 6733): at androidx.compose.ui.platform.AbstractComposeView$ensureCompositionCreated$1.invoke(ComposeView.android.kt:251) E/AndroidRuntime( 6733): at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:109) E/AndroidRuntime( 6733): at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35) E/AndroidRuntime( 6733): at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:228) E/AndroidRuntime( 6733): at androidx.compose.ui.platform.CompositionLocalsKt.ProvideCommonCompositionLocals(CompositionLocals.kt:186) E/AndroidRuntime( 6733): at androidx.compose.ui.platform.AndroidCompositionLocals_androidKt$ProvideAndroidCompositionLocals$3.invoke(AndroidCompositionLocals.android.kt:119) E/AndroidRuntime( 6733): at androidx.compose.ui.platform.AndroidCompositionLocals_androidKt$ProvideAndroidCompositionLocals$3.invoke(AndroidCompositionLocals.android.kt:118) E/AndroidRuntime( 6733): at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:109) E/AndroidRuntime( 6733): at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35) E/AndroidRuntime( 6733): at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:228) E/AndroidRuntime( 6733): at androidx.compose.ui.platform.AndroidCompositionLocals_androidKt.ProvideAndroidCompositionLocals(AndroidCompositionLocals.android.kt:110) E/AndroidRuntime( 6733): at androidx.compose.ui.platform.WrappedComposition$setContent$1$1$2.invoke(Wrapper.android.kt:139) E/AndroidRuntime( 6733): at androidx.compose.ui.platform.WrappedComposition$setContent$1$1$2.invoke(Wrapper.android.kt:138) E/AndroidRuntime( 6733): at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:109) E/AndroidRuntime( 6733): at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35) E/AndroidRuntime( 6733): at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:248) E/AndroidRuntime( 6733): at androidx.compose.ui.platform.WrappedComposition$setContent$1$1.invoke(Wrapper.android.kt:138) E/AndroidRuntime( 6733): at androidx.compose.ui.platform.WrappedComposition$setContent$1$1.invoke(Wrapper.android.kt:123) E/AndroidRuntime( 6733): at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:109) E/AndroidRuntime( 6733): at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35) E/AndroidRuntime( 6733): at androidx.compose.runtime.ActualJvm_jvmKt.invokeComposable(ActualJvm.jvm.kt:90) E/AndroidRuntime( 6733): at androidx.compose.runtime.ComposerImpl.doCompose(Composer.kt:3302) E/AndroidRuntime( 6733): at androidx.compose.runtime.ComposerImpl.composeContent$runtime_release(Composer.kt:3235) E/AndroidRuntime( 6733): at androidx.compose.runtime.CompositionImpl.composeContent(Composition.kt:723) E/AndroidRuntime( 6733): at androidx.compose.runtime.Recomposer.composeInitial$runtime_release(Recomposer.kt:1071) E/AndroidRuntime( 6733): at androidx.compose.runtime.CompositionImpl.composeInitial(Composition.kt:631) E/AndroidRuntime( 6733): at androidx.compose.runtime.CompositionImpl.setContent(Composition.kt:617) E/AndroidRuntime( 6733): at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:123) E/AndroidRuntime( 6733): at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:114) E/AndroidRuntime( 6733): at androidx.compose.ui.platform.AndroidComposeView.setOnViewTreeOwnersAvailable(AndroidComposeView.android.kt:1289) E/AndroidRuntime( 6733): at androidx.compose.ui.platform.WrappedComposition.setContent(Wrapper.android.kt:114) E/AndroidRuntime( 6733): at androidx.compose.ui.platform.WrappedComposition.onStateChanged(Wrapper.android.kt:164) E/AndroidRuntime( 6733): at androidx.lifecycle.LifecycleRegistry$ObserverWithState.dispatchEvent(LifecycleRegistry.kt:314) E/AndroidRuntime( 6733): at androidx.lifecycle.LifecycleRegistry.addObserver(LifecycleRegistry.kt:192) E/AndroidRuntime( 6733): at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:121) E/AndroidRuntime( 6733): at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:114) E/AndroidRuntime( 6733): at androidx.compose.ui.platform.AndroidComposeView.onAttachedToWindow(AndroidComposeView.android.kt:1364) E/AndroidRuntime( 6733): at android.view.View.dispatchAttachedToWindow(View.java:20479) E/AndroidRuntime( 6733): at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3489) E/AndroidRuntime( 6733): at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3496) E/AndroidRuntime( 6733): at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3496) E/AndroidRuntime( 6733): at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3496) E/AndroidRuntime( 6733): at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3496) E/AndroidRuntime( 6733): at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3496) E/AndroidRuntime( 6733): at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3496) E/AndroidRuntime( 6733): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2417) E/AndroidRuntime( 6733): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1952) E/AndroidRuntime( 6733): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8171) E/AndroidRuntime( 6733): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:972) E/AndroidRuntime( 6733): at android.view.Choreographer.doCallbacks(Choreographer.java:796) E/AndroidRuntime( 6733): at android.view.Choreographer.doFrame(Choreographer.java:731) E/AndroidRuntime( 6733): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:957) E/AndroidRuntime( 6733): at android.os.Handler.handleCallback(Handler.java:938) E/AndroidRuntime( 6733): at android.os.Handler.dispatchMessage(Handler.java:99) E/AndroidRuntime( 6733): at android.os.Looper.loop(Looper.java:223) E/AndroidRuntime( 6733): at android.app.ActivityThread.main(ActivityThread.java:7656) E/AndroidRuntime( 6733): at java.lang.reflect.Method.invoke(Native Method) E/AndroidRuntime( 6733): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) E/AndroidRuntime( 6733): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947) E/AndroidRuntime( 6733): Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.compose.ui.platform.LocalSoftwareKeyboardController" on path: DexPathList[[zip file "/data/app/TGM_Os2yASdUotdbjGfBnQ==/U76uF0EGgZeHNTj3XwInfg==/base.apk"],nativeLibraryDirectories=[/data/app/TGM_Os2yASdUotdbjGfBnQ==/U76uF0EGgZeHNTj3XwInfg==/lib/x86, /data/app/~~TGM_Os2yASdUotdbjGfBnQ==/U76uF0EGgZeHNTj3XwInfg==/base.apk!/lib/x86, /system/lib, /system_ext/lib]] E/AndroidRuntime( 6733): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:207) E/AndroidRuntime( 6733): at java.lang.ClassLoader.loadClass(ClassLoader.java:379) E/AndroidRuntime( 6733): at java.lang.ClassLoader.loadClass(ClassLoader.java:312) E/AndroidRuntime( 6733): ... 90 more

Mik77o commented 6 months ago

Probably it's related to this issue: https://github.com/stripe/stripe-android/issues/7184#issuecomment-1776245431

Mik77o commented 6 months ago

We experience the same error. The application suddenly started crashing.

Mik77o commented 6 months ago

Our current workaround

  1. Adding app/src/main/kotlin/androidx/compose/ui/platform/LocalSoftwareKeyboardController.kt
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
}
  1. Changes in build.gradle
android {

...

   buildFeatures {
       compose true
   }

   composeOptions {
       kotlinCompilerExtensionVersion '1.4.8'
   }
}

...

dependencies {
...
    implementation "androidx.compose.ui:ui:1.6.1"
    implementation "androidx.compose.ui:ui-tooling:1.6.1"
}

We use ext.kotlin_version = '1.8.22'.

j-mary commented 6 months ago

Our current workaround

  1. Adding app/src/main/kotlin/androidx/compose/ui/platform/LocalSoftwareKeyboardController.kt
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
}
  1. Changes in build.gradle
android {

...

   buildFeatures {
       compose true
   }

   composeOptions {
       kotlinCompilerExtensionVersion '1.4.8'
   }
}

...

dependencies {
...
    implementation "androidx.compose.ui:ui:1.6.1"
    implementation "androidx.compose.ui:ui-tooling:1.6.1"
}

We use ext.kotlin_version = '1.8.22'.

@Mik77o thanks for the workaround. It works.

remonh87 commented 5 months ago

Waiting for Stripe reactnative to fix it.