Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expected Android API level 21+ but was 30 #128

Closed
xxllexx opened this issue Mar 16, 2021 · 10 comments
Closed

Expected Android API level 21+ but was 30 #128

xxllexx opened this issue Mar 16, 2021 · 10 comments

Comments

@xxllexx
Copy link

xxllexx commented Mar 16, 2021

Summary

Trying to build an app for the API Level 30 and got the exception in initialize phase
Stack trace shows that the problem cames from com.stripe.okhttp3.internal.platform package.

2021-03-15 18:04:18.098 29073-29073/com.wix.android.dev E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.wix.android.dev, PID: 29073
    java.lang.ExceptionInInitializerError
        at com.stripe.okhttp3.OkHttpClient.<init>(OkHttpClient.kt:219)
        at com.stripe.okhttp3.OkHttpClient.<init>(OkHttpClient.kt:211)
        at com.stripe.stripeterminal.HttpModule.provideOkHttpClient(HttpModule.kt:14)
        at com.stripe.stripeterminal.HttpModule_ProvideOkHttpClientFactory.provideOkHttpClient(HttpModule_ProvideOkHttpClientFactory.java:29)
        at com.stripe.stripeterminal.HttpModule_ProvideOkHttpClientFactory.get(HttpModule_ProvideOkHttpClientFactory.java:21)
        at com.stripe.stripeterminal.HttpModule_ProvideOkHttpClientFactory.get(HttpModule_ProvideOkHttpClientFactory.java:8)
        at dagger.internal.DoubleCheck.get(DoubleCheck.java:47)
        at com.stripe.stripeterminal.api.ApiClient_Factory.get(ApiClient_Factory.java:25)
        at com.stripe.stripeterminal.api.ApiClient_Factory.get(ApiClient_Factory.java:8)
        at dagger.internal.DoubleCheck.get(DoubleCheck.java:47)
        at com.stripe.stripeterminal.dagger.IpReaderModule_ProvideIpReaderControllerFactory.get(IpReaderModule_ProvideIpReaderControllerFactory.java:32)
        at com.stripe.stripeterminal.dagger.IpReaderModule_ProvideIpReaderControllerFactory.get(IpReaderModule_ProvideIpReaderControllerFactory.java:11)
        at dagger.internal.DoubleCheck.get(DoubleCheck.java:47)
        at com.stripe.stripeterminal.dagger.TerminalModule_ProvideIpReaderAdapterFactory.get(TerminalModule_ProvideIpReaderAdapterFactory.java:37)
        at com.stripe.stripeterminal.dagger.TerminalModule_ProvideIpReaderAdapterFactory.get(TerminalModule_ProvideIpReaderAdapterFactory.java:12)
        at dagger.internal.DoubleCheck.get(DoubleCheck.java:47)
        at com.stripe.stripeterminal.dagger.TerminalModule_ProvideMasterAdapterFactory.get(TerminalModule_ProvideMasterAdapterFactory.java:42)
        at com.stripe.stripeterminal.dagger.TerminalModule_ProvideMasterAdapterFactory.get(TerminalModule_ProvideMasterAdapterFactory.java:13)
        at dagger.internal.DoubleCheck.get(DoubleCheck.java:47)
        at com.stripe.stripeterminal.TerminalSession_Factory.get(TerminalSession_Factory.java:46)
        at com.stripe.stripeterminal.TerminalSession_Factory.get(TerminalSession_Factory.java:10)
        at dagger.internal.DoubleCheck.get(DoubleCheck.java:47)
        at com.stripe.stripeterminal.log.TraceFactory_Factory.get(TraceFactory_Factory.java:26)
        at com.stripe.stripeterminal.log.TraceFactory_Factory.get(TraceFactory_Factory.java:9)
        at dagger.internal.DoubleCheck.get(DoubleCheck.java:47)
        at com.stripe.stripeterminal.dagger.DaggerTerminalComponent.getTraceFactory(DaggerTerminalComponent.java:207)
        at com.stripe.stripeterminal.Terminal$Companion.initTerminal(Terminal.kt:448)
        at com.reactnativestripepos.TerminalDiscovery.initialize(TerminalDiscovery.kt:34)
        at com.reactnativestripepos.StripePosModule.initSdk(StripePosModule.kt:68)
        at com.reactnativestripepos.StripePosPackage.onRequestPermissionsResult(StripePosPackage.kt:33)
        at com.wix.WixApplication.onRequestPermissionsResult(WixApplication.kt:111)
        at com.reactnativenavigation.NavigationActivity.onRequestPermissionsResult(NavigationActivity.java:134)
        at com.wix.MainActivity.onRequestPermissionsResult(MainActivity.kt:40)
        at android.app.Activity.dispatchRequestPermissionsResult(Activity.java:8466)
        at android.app.Activity.dispatchActivityResult(Activity.java:8314)
        at android.app.ActivityThread.deliverResults(ActivityThread.java:5008)
        at android.app.ActivityThread.handleSendResult(ActivityThread.java:5056)
        at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:51)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:223)
        at android.app.ActivityThread.main(ActivityThread.java:7656)
        at java.lang.reflect.Method.invoke(Native Method)
2021-03-15 18:04:18.101 29073-29073/com.wix.android.dev E/AndroidRuntime:     at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
     Caused by: java.lang.IllegalStateException: Expected Android API level 21+ but was 30
        at com.stripe.okhttp3.internal.platform.AndroidPlatform$Companion.buildIfSupported(AndroidPlatform.kt:370)
        at com.stripe.okhttp3.internal.platform.Platform$Companion.findPlatform(Platform.kt:204)
        at com.stripe.okhttp3.internal.platform.Platform$Companion.access$findPlatform(Platform.kt:178)
        at com.stripe.okhttp3.internal.platform.Platform.<clinit>(Platform.kt:179)
        	... 47 more
2021-03-15 18:04:18.257 29073-29073/com.wix.android.dev W/com.newrelic.android: Previous uncaught exception handler[org.chromium.base.JavaExceptionReporter] was set after agent start. Let it be...
2021-03-15 18:04:18.398 29073-29462/com.wix.android.dev D/WixOneApp: [okhttp] Received response for https://ecom.wix.com/_api/wix-ecommerce-graphql-web/api with HTTP status code: 200
2021-03-15 18:04:19.680 29073-29345/com.wix.android.dev I/com.newrelic.android: Crash ac6e7993-c40e-4638-b8c1-00359ada6280 successfully submitted.
2021-03-15 18:04:19.918 29073-29073/com.wix.android.dev I/Process: Sending signal. PID: 29073 SIG: 9

Code to reproduce

The simple call Terminal.initTerminal(context, LogLevel.VERBOSE, ConnectionTokenProvider, DiscoveryListener)

Android version

Android 11

Impacted devices (Android devices or readers)

Any device with Android 11 and emulator

SDK version

com.stripe:stripeterminal:1.0.17

Other information

I've checked com.stripe.okhttp3.internal.platform.AndroidPlatform which i found in the stacktrace above.
And found this code

if (VERSION.SDK_INT >= 21) {
                try {
                    Method setUseSessionTickets = sslSocketClass.getDeclaredMethod("setUseSessionTickets", Boolean.TYPE);
                    Method setHostname = sslSocketClass.getMethod("setHostname", String.class);
                    Method getAlpnSelectedProtocol = sslSocketClass.getMethod("getAlpnSelectedProtocol");
                    Method setAlpnProtocols = sslSocketClass.getMethod("setAlpnProtocols", byte[].class);
                    Intrinsics.checkExpressionValueIsNotNull(setUseSessionTickets, "setUseSessionTickets");
                    Intrinsics.checkExpressionValueIsNotNull(setHostname, "setHostname");
                    Intrinsics.checkExpressionValueIsNotNull(getAlpnSelectedProtocol, "getAlpnSelectedProtocol");
                    Intrinsics.checkExpressionValueIsNotNull(setAlpnProtocols, "setAlpnProtocols");
                    return (Platform)(new AndroidPlatform(sslParametersClass, sslSocketClass, setUseSessionTickets, setHostname, getAlpnSelectedProtocol, setAlpnProtocols));
                } catch (NoSuchMethodException var8) {
                }
            }

            throw (Throwable)(new IllegalStateException("Expected Android API level 21+ but was " + VERSION.SDK_INT));

Seems like those non-sdk methods (eg: setUseSessionTickets, setHostname, etc.) were moved or changed in Android 11
https://developer.android.com/about/versions/11/non-sdk-11

@billfinn-stripe
Copy link
Collaborator

Hi Alex -- as an immediate workaround, you can target API level 29. We'll keep this issue open until we provide a permanent fix.

@xxllexx
Copy link
Author

xxllexx commented Mar 16, 2021

I would do this if I can, but the module which interact with the stripe sdk, is the part of big application, which was migrated to Level 30.
Do you have some ETA for permanent fix?

@billfinn-stripe
Copy link
Collaborator

Do you have some ETA for permanent fix?

We have a release scheduled for later in Q2.

@xxllexx
Copy link
Author

xxllexx commented Mar 16, 2021

Thanks, let's keep it open till then.

@billfinn-stripe
Copy link
Collaborator

Hi Alex -- I have confirmed locally that our internal beta release does fix this issue. So, this issue will be fixed in the next public release later in Q2. It will be a 2.x beta release.

@xxllexx
Copy link
Author

xxllexx commented Mar 16, 2021

is it possible for me to try the beta?

@billfinn-stripe
Copy link
Collaborator

is it possible for me to try the beta?

Hi Alex -- unfortunately, right now, we're limiting the beta release to a small set of users.

@billfinn-stripe
Copy link
Collaborator

Hi Alex -- I have good news. We've released 1.0.18, which I believe has fixed this issue. I'm going to optimistically close this, but feel free to reopen or create a new issue if you have the same or a similar problem.

@xxllexx
Copy link
Author

xxllexx commented Mar 23, 2021

Thanks a lot. I'm going to check it upcoming days.

@malinajirka
Copy link

I can confirm the fix works as expected ;). Thanks for working on this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants