Stripe-android: Why does the sdk depend on RC versions of androidx artifacts?

Created on 19 Jan 2021  路  17Comments  路  Source: stripe/stripe-android

Summary

The stripe sdk depends on unstable (release candidate) versions of some androidx artifacts. Looks like in commit 97c3ac31e5d47759fca6c7e3258ae2912707ab56, for example, these versions were specified:

  • androidx fragment: 1.2.5 or maybe 1.3.0-rc01 (I see both in that commit)
  • androidx activity: 1.2.0-rc01

We prefer to stay on stable versions of libraries whenever possible.

I did try to force stable versions of these libraries with a resolutionStrategy in our project's build.gradle, and that resulted in crashes when opening the stripe UI for the card list. (java.lang.NoClassDefFoundError: Failed resolution of: androidx/activity/result/contract/ActivityResultContract;)

I don't have enough info right now to provide details of the crash.

For now:
:one: I'd just like to know if there's a specific reason stripe depends on these rc versions.
:two: I'd also like to request to depend on stable versions in the future, if possible.

Thanks!

SDK version

16.2.0


UPDATE: I may try to answer :one: "why" myself 馃槃 :

  • AddPaymentMethodContract.kt uses ActivityResultContract which is only available in the 1.2.0-rc1 version of the activity artifact.
  • By forcing our project to stay on the 1.1.0 stable version of activity, the stripe ui crashes because this class isn't available.
triaged

Most helpful comment

@calvarez-ov yes, planning on doing a new release with the stable artifacts today.

See changelog: https://github.com/stripe/stripe-android/pull/3371/

All 17 comments

@calvarez-ov thanks for filing this issue. I'd like to apologize for the inconvenience that this release caused. We noted this dependency in our changelog, but there might be other ways of publicizing these changes. We don't have a stated policy about dependency version stability, but I agree that including an RC artifact introduces integration issues and should be avoided unless absolutely necessary.

For now, I would recommend rolling back to Stripe SDK v16.1.1.

Thanks for the response. Indeed, I missed this note in the changelog!

~You can close is issue :)~

Actually I prefer to keep this open. It's concerning that new updates are being made to the stripe sdk, that we can't take advantage of, unless we accept to have dependencies on unstable androidx artifacts.

One more note: It looks like fragment 1.3.0-rc01 is also required.

If I force fragment to the latest stable (1.2.5), (but keep the 1.2.0-rc01 for activity): the app crashes when launching the activity to create a new card, from the activity with the list of cards:

Process: com.stripe.example, PID: 8488
java.lang.IllegalArgumentException: Can only use lower 16 bits for requestCode
        at androidx.fragment.app.FragmentActivity.checkForValidRequestCode(FragmentActivity.java:714)
        at androidx.fragment.app.FragmentActivity.startActivityForResult(FragmentActivity.java:672)
        at androidx.core.app.ActivityCompat.startActivityForResult(ActivityCompat.java:234)
        at androidx.activity.ComponentActivity$2.onLaunch(ComponentActivity.java:218)
        at androidx.activity.result.ActivityResultRegistry$2.launch(ActivityResultRegistry.java:162)
        at androidx.activity.result.ActivityResultLauncher.launch(ActivityResultLauncher.java:47)
        at com.stripe.android.view.PaymentMethodsActivity$onCreate$4.onChanged(PaymentMethodsActivity.kt:116)
        at com.stripe.android.view.PaymentMethodsActivity$onCreate$4.onChanged(PaymentMethodsActivity.kt:35)
        at androidx.lifecycle.LiveData.considerNotify(LiveData.java:133)
        at androidx.lifecycle.LiveData.dispatchingValue(LiveData.java:151)
        at androidx.lifecycle.LiveData.setValue(LiveData.java:309)
        at androidx.lifecycle.MutableLiveData.setValue(MutableLiveData.java:50)
        at androidx.lifecycle.Transformations$3.onChanged(Transformations.java:188)
        at androidx.lifecycle.MediatorLiveData$Source.onChanged(MediatorLiveData.java:152)
        at androidx.lifecycle.LiveData.considerNotify(LiveData.java:133)
        at androidx.lifecycle.LiveData.dispatchingValue(LiveData.java:151)
        at androidx.lifecycle.LiveData.setValue(LiveData.java:309)
        at androidx.lifecycle.MutableLiveData.setValue(MutableLiveData.java:50)
        at com.stripe.android.view.PaymentMethodsAdapter$onBindViewHolder$3.onClick(PaymentMethodsAdapter.kt:154)
        at android.view.View.performClick(View.java:7448) 
        at android.view.View.performClickInternal(View.java:7425)
        at android.view.View.access$3600(View.java:810) 
        at android.view.View$PerformClick.run(View.java:28305)
        at android.os.Handler.handleCallback(Handler.java:938)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:223)      
        at android.app.ActivityThread.main(ActivityThread.java:7656)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)

Maybe that should go into the release notes as well?

Also, lifecycle 2.3.0-rc01 is required. If I force it to stable 2.2.0 (but keep the rc versions for fragment and activity), I get another crash, when opening the "fragment examples":

 Process: com.stripe.example, PID: 10752
 java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/lifecycle/ViewTreeLifecycleOwner; 
        at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2957)
        at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:515)
        at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:282)
        at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:2177)
        at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:2088)
        at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1990)
        at androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:3122)
        at androidx.fragment.app.FragmentManager.dispatchActivityCreated(FragmentManager.java:3056)
        at androidx.fragment.app.FragmentController.dispatchActivityCreated(FragmentController.java:251)
        at androidx.fragment.app.FragmentActivity.onStart(FragmentActivity.java:473)
        at androidx.appcompat.app.AppCompatActivity.onStart(AppCompatActivity.java:210)
        at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1435)
        at android.app.Activity.performStart(Activity.java:8024)
        at android.app.ActivityThread.handleStartActivity(ActivityThread.java:3475)
        at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:221)
        at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:201)
        at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:173)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
        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)
        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.ClassNotFoundException: Didn't find class "androidx.lifecycle.ViewTreeLifecycleOwner" on path: DexPathList[[zip file "/data/app/~~oR8tIM6svw3_38qSC7EmkA==/com.stripe.example-_WWkaScklKO6bP-IT1YSNg==/base.apk"],nativeLibraryDirectories=[/data/app/~~oR8tIM6svw3_38qSC7EmkA==/com.stripe.example-_WWkaScklKO6bP-IT1YSNg==/lib/x86, /system/lib, /system_ext/lib]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:207)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
        ... 25 more

Another thing to mention in the release notes perhaps?

This is not the first time Stripe Android is pulling in non-stable dependencies :/

Version 12.7.0 (more than 1 year ago) pulled in some alpha-versions of Material: https://github.com/stripe/stripe-android/issues/1966

Pulling in 1.3.0-rc01 of fragment-ktx ends up pulling in release-candidate versions of:

fragment-ktx >= 1.3.0-rc01
activity-ktx >= 1.2.0-rc01
activity == [1.2.0-rc01]
fragment == [1.3.0-rc01]
lifecycle-livedata-core-ktx >= 2.3.0-rc01
lifecycle-runtime >= 2.3.0-rc01
lifecycle-common >= 2.3.0-rc01
lifecycle-viewmodel-ktx >= 2.3.0-rc01
lifecycle-viewmodel >= 2.3.0-rc01
savedstate-ktx >= 1.1.0-rc01
savedstate == [1.1.0-rc01]

Quite a few of these bring in breaking changes, as pointed out above.

I see there's a new release of the stripe sdk, 16.2.1, which has one item which could be interesting:

3315 Upgrade 3DS2 SDK to 5.1.1

The problem is that 16.2.1 still depends on unstable versions of androidx libraries.

We would like to have the latest 3DS2 library, if it has important updates, without having to rely on unstable androidx artifacts.

@calvarez-ov thanks for the feedback. I'm anticipating that a stable version will be released soon [0], which will allow you to upgrade.

[0] https://twitter.com/ianhlake/status/1354530728558489600

These dependencies have graduated to stable: https://github.com/stripe/stripe-android/pull/3367

Will we have a new release of Stripe, which will depend on the new stable versions of the androidx artifacts?

@calvarez-ov yes, planning on doing a new release with the stable artifacts today.

See changelog: https://github.com/stripe/stripe-android/pull/3371/

I noticed in the release notes of activity 1.2.0 :

Note: When using AppCompatActivity, you must use AppCompat 1.3.0-alpha01 or higher to gain ViewTree support.

Will the new stripe release have a direct or transitive dependency on this alpha version of app compat?

@calvarez-ov It sounds like that only applies if the SDK needs to "gain ViewTree support."

Does stripe need viewtree support?

@calvarez-ov no, we don't depend on ViewTree support. The latest Android SDK release will not be depending on any non-release Jetpack libraries. :)

awesome, thanks! 馃檱

Thanks for your feedback regarding the RC dependencies.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

HanteIsHante picture HanteIsHante  路  9Comments

danielgomezrico picture danielgomezrico  路  6Comments

OleksandrGrument picture OleksandrGrument  路  10Comments

odedharth picture odedharth  路  4Comments

odedharth picture odedharth  路  10Comments