checkout / frames-android

Frames Android: making native card payments simple
https://www.checkout.com/docs/integrate/sdks/android-sdk
MIT License
47 stars 32 forks source link

Crash with latest stable compose version #273

Open laurentvoodoo opened 2 months ago

laurentvoodoo commented 2 months ago

Describe the bug Crash when use latest stable compose version 1.6.x when create new card

Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/compose/ui/platform/LocalSoftwareKeyboardController;
    at com.checkout.frames.screen.paymentdetails.PaymentDetailsScreenKt.PaymentDetailsScreen(PaymentDetailsScreen.kt:108)
    at com.checkout.frames.screen.paymentdetails.PaymentDetailsScreenKt$PaymentDetailsScreen$4.invoke(Unknown Source:14)
    at com.checkout.frames.screen.paymentdetails.PaymentDetailsScreenKt$PaymentDetailsScreen$4.invoke(Unknown Source:10)
    at androidx.compose.runtime.RecomposeScopeImpl.compose(RecomposeScopeImpl.kt:192)
    at androidx.compose.runtime.ComposerImpl.recomposeToGroupEnd(Composer.kt:2556)
    at androidx.compose.runtime.ComposerImpl.skipCurrentGroup(Composer.kt:2827)
    at androidx.compose.runtime.ComposerImpl.doCompose(Composer.kt:3314)
    at androidx.compose.runtime.ComposerImpl.recompose$runtime_release(Composer.kt:3265)
    at androidx.compose.runtime.CompositionImpl.recompose(Composition.kt:940)
    at androidx.compose.runtime.Recomposer.performRecompose(Recomposer.kt:1155)
    at androidx.compose.runtime.Recomposer.access$performRecompose(Recomposer.kt:127)
    at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2$1.invoke(Recomposer.kt:583)
    at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2$1.invoke(Recomposer.kt:551)
    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:1229)
    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1239)
    at android.view.Choreographer.doCallbacks(Choreographer.java:899)
    at android.view.Choreographer.doFrame(Choreographer.java:827)
    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1214)
    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:7918)
    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)
    Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [androidx.compose.runtime.PausableMonotonicFrameClock@39fa1cf, androidx.compose.ui.platform.MotionDurationScaleImpl@35f275c, StandaloneCoroutine{Cancelling}@aa9fa65, AndroidUiDispatcher@3c8933a]
Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.compose.ui.platform.LocalSoftwareKeyboardController" on path: DexPathList[[zip file "/data/app/~~I5ewptY7ldNtJslHKr51Hw==/app.test-tm0xLoPDlBDaesM9Ohyoyw==/base.apk", dex file "InMemoryDexFile[cookie=[0, -5476376625613283856]]", dex file "InMemoryDexFile[cookie=[0, -5476376625613287664]]"],nativeLibraryDirectories=[/data/app/~~I5ewptY7ldNtJslHKr51Hw==/app.test-tm0xLoPDlBDaesM9Ohyoyw==/lib/arm64, /data/app/~~I5ewptY7ldNtJslHKr51Hw==/app.test-tm0xLoPDlBDaesM9Ohyoyw==/base.apk!/lib/arm64-v8a, /system/lib64, /system_ext/lib64]]
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:259)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:379)

To Reproduce Set compose version to 1.6.5 Add new card Fill some fields or navigate between them , keyboard will hide and show Crash appears

Expected behavior No crash with compose latest stable version

konecnyna commented 2 months ago

LocalSoftwareKeyboardController was removed from the composition local provider in Compose version 1.6.0.

Seems the Frames project is running off of Compose version 1.5.3

My work around was this:

val keyboardController = LocalSoftwareKeyboardController.current
val paymentFormMediator = remember { PaymentFormMediator(paymentFormConfig) } 
CompositionLocalProvider(
   LocalSoftwareKeyboardController provides keyboardController
) {
   paymentFormMediator.PaymentForm()
}

Which shows me the keyboard without crashing.

This does not fix it. Continues to crash.

konecnyna commented 2 weeks ago

After working with the team found the solution here

Be sure to check your progaurd config as well!