stripe / stripe-terminal-android

Stripe Terminal Android SDK
https://stripe.dev/stripe-terminal-android/
Other
94 stars 46 forks source link

Incompatibility with OkHttp 5.0.0-alpha.14 in Stripe Terminal Android SDK #501

Open mehulrewardle opened 2 months ago

mehulrewardle commented 2 months ago

Summary

When integrating the Stripe Terminal Android SDK (v3.9.1) with the AWS Amplify Framework (com.amplifyframework:aws-auth-cognito:2.18.0), which relies on okhttp 5.0.0-alpha.14, the application crashes due to a NoClassDefFoundError for okhttp3.internal.Util.

Code to reproduce

// Add Stripe Terminal SDK implementation "com.stripe:stripeterminal:3.9.1" implementation "com.stripe:stripeterminal-localmobile:3.9.1"

// Add AWS Amplify Cognito Auth (which uses OkHttp 5.0.0-alpha.14) implementation('com.amplifyframework:aws-auth-cognito:2.18.0')

Steps:

Initialize the Stripe Terminal SDK using Terminal.initTerminal. The app crashes with a NoClassDefFoundError.

Error log:

java.lang.NoClassDefFoundError: Failed resolution of: Lokhttp3/internal/Util; at okhttp3.tls.HandshakeCertificates$Builder.build(HandshakeCertificates.kt:174) at com.stripe.jvmcore.httptls.dagger.HttpTlsModule.provideHandshakeCertificates(HttpTlsModule.kt:19) at com.stripe.jvmcore.httptls.dagger.HttpTlsModule_ProvideHandshakeCertificatesFactory.provideHandshakeCertificates(HttpTlsModule_ProvideHandshakeCertificatesFactory.java:48) at com.stripe.jvmcore.httptls.dagger.HttpTlsModule_ProvideHandshakeCertificatesFactory.get(HttpTlsModule_ProvideHandshakeCertificatesFactory.java:39) at com.stripe.jvmcore.httptls.dagger.HttpTlsModule_ProvideHandshakeCertificatesFactory.get(HttpTlsModule_ProvideHandshakeCertificatesFactory.java:14) at com.stripe.jvmcore.client.dagger.HttpClientBaseModule_ProvideHttpClientFactory.get(HttpClientBaseModule_ProvideHttpClientFactory.java:56) at com.stripe.jvmcore.client.dagger.HttpClientBaseModule_ProvideHttpClientFactory.get(HttpClientBaseModule_ProvideHttpClientFactory.java:17) at dagger.internal.DoubleCheck.get(DoubleCheck.java:47) at com.stripe.stripeterminal.dagger.LogModule_ProvideCrpcClientFactory.get(LogModule_ProvideCrpcClientFactory.java:63) at com.stripe.stripeterminal.dagger.LogModule_ProvideCrpcClientFactory.get(LogModule_ProvideCrpcClientFactory.java:16) at dagger.internal.DoubleCheck.get(DoubleCheck.java:47) at com.stripe.stripeterminal.dagger.LogModule_ProvideClientLoggerApiFactory.get(LogModule_ProvideClientLoggerApiFactory.java:37) at com.stripe.stripeterminal.dagger.LogModule_ProvideClientLoggerApiFactory.get(LogModule_ProvideClientLoggerApiFactory.java:13) at dagger.internal.DoubleCheck.get(DoubleCheck.java:47) at com.stripe.jvmcore.logging.terminal.log.DeviceRoleLogUploader_Factory.get(DeviceRoleLogUploader_Factory.java:45) at com.stripe.jvmcore.logging.terminal.log.DeviceRoleLogUploader_Factory.get(DeviceRoleLogUploader_Factory.java:11) at dagger.internal.DoubleCheck.get(DoubleCheck.java:47) at com.stripe.stripeterminal.dagger.LogModule_ProvideLogUploaderFactory.get(LogModule_ProvideLogUploaderFactory.java:37) at com.stripe.stripeterminal.dagger.LogModule_ProvideLogUploaderFactory.get(LogModule_ProvideLogUploaderFactory.java:13) at dagger.internal.DoubleCheck.get(DoubleCheck.java:47) at com.stripe.jvmcore.logging.terminal.dagger.JvmCoreLogModule_ProvideLogFlusher$logging_terminalFactory.get(JvmCoreLogModule_ProvideLogFlusher$logging_terminalFactory.java:47) at com.stripe.jvmcore.logging.terminal.dagger.JvmCoreLogModule_ProvideLogFlusher$logging_terminalFactory.get(JvmCoreLogModule_ProvideLogFlusher$logging_terminalFactory.java:15) at dagger.internal.DoubleCheck.get(DoubleCheck.java:47) at com.stripe.stripeterminal.DaggerTerminalComponent$TerminalComponentImpl.getTraceFlusher(DaggerTerminalComponent.java:2510) at com.stripe.stripeterminal.Terminal$Companion.initTerminal(Terminal.kt:1057) at com.stripe.stripeterminal.Terminal$Companion.initTerminal(Terminal.kt:975) at com.stripe.stripeterminal.Terminal.initTerminal(Unknown Source:2)

Android version

Tested on Android 11

Impacted devices (Android devices or readers)

Android device

SDK version

Stripe Terminal SDK version: 3.9.1 OkHttp version: 5.0.0-alpha.14 (forced due to AWS Amplify dependency)

Other information

Suggested Resolution: Update the Stripe Terminal SDK to support OkHttp 5.x or provide a fallback mechanism for projects relying on newer OkHttp versions

ugochukwu-stripe commented 2 months ago

Hi @mehulrewardle, thanks for reporting this; we currently do not have concrete timelines for when we'd integrate okhttp 5 in stripe terminal. Have you tried pulling in the okhttp-tls^1 library from the same okhttp version as a work around? Stripe terminal relies on version 4.12 ^2, and the mismatch is most likely the root cause of this error.

Please let us know if the workaround resolves the issue for you; you'd also want to upgrade to the latest release 3.9.3 that resolves reported issues in 3.9.1^3 .