Stripe-android: Attempted to get instance of CustomerSession without initialization.

Created on 22 Jan 2019  Â·  9Comments  Â·  Source: stripe/stripe-android

Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{PkgName/com.stripe.android.view.PaymentFlowActivity}: java.lang.IllegalStateException: Attempted to get instance of CustomerSession without initialization.
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2419)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2479)
       at android.app.ActivityThread.-wrap11(ActivityThread.java)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1347)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:148)
       at android.app.ActivityThread.main(ActivityThread.java:5420)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by java.lang.IllegalStateException: Attempted to get instance of CustomerSession without initialization.
       at com.stripe.android.CustomerSession.getInstance(CustomerSession.java:120)
       at com.stripe.android.view.PaymentFlowActivity.onCreate(PaymentFlowActivity.java:55)
       at android.app.Activity.performCreate(Activity.java:6280)
       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2372)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2479)
       at android.app.ActivityThread.-wrap11(ActivityThread.java)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1347)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:148)
       at android.app.ActivityThread.main(ActivityThread.java:5420)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

Use:

compile 'com.stripe:stripe-android:8.1.0'

I have done the initialization, as follows:

 val stripe =  Stripe(context,  STRIPE_PUBLISH_TEST_KEY)

I don't know why the above error log appears.

Most helpful comment

We've had many successful transactions since the last time we saw this in December and a few since (on a Nexus 6, Android 7.1.1, as it was reported) just to test. It only shows up in crashlytics, so I'm not sure under which conditions it's occurring, or how to reproduce it. I have a vague suspicion it might be related to some automation either in the google play store or elsewhere, that might be loading screens out of order or too quickly or something like that, but it's a wild guess in the dark. I have no evidence to support this and the google play store tests appear to have all passed (maybe there's a delay in reporting...?). It's infrequent enough for us to accept as "a thing that happens sometimes" but I figured you and posterity might be interested to know that it's still out there. Of course, resolving it would be ideal though, so let me know if you have any ideas or want more info. Thanks

All 9 comments

@HanteIsHante you need to call CustomerSession#initCustomerSession before you launch PaymentFlowActivity, or more generally, before you attempt to call CustomerSession#getInstance().

See https://github.com/stripe/stripe-android/blob/master/example/src/main/java/com/stripe/example/activity/PaymentSessionActivity.java#L110 for an example in our codebase.

Let me know if this fixes the issue. If so, we can close out the issue.

I am in the payment process through PaymentInent. Is it necessary to perform the CustomerSession initialization?

This problem only happens occasionally, I can't reproduce this problem.

@HanteIsHante I believe you need to start with PaymentSessionActivity, which launches PaymentFlowActivity. Does that fix it?

@HanteIsHante please reopen if the above recommendation did not resolve the issue

Crashlytics just reported this intermittent bug from one of our users in production. I don't have a lot to go on at the moment, but FYI it's still out there.

@ThomasGHenry can you provide a stacktrace? What version of stripe-android was the user on?

stripe-android 8.1.0 via tipsi-stripe 7.5.0 on react native

Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.app_redacted.app/com.stripe.android.view.PaymentFlowActivity}: java.lang.IllegalStateException: Attempted to get instance of CustomerSession without initialization.
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2665)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
       at android.app.ActivityThread.-wrap12(ActivityThread.java)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:154)
       at android.app.ActivityThread.main(ActivityThread.java:6119)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
       at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:107)
Caused by java.lang.IllegalStateException: Attempted to get instance of CustomerSession without initialization.
       at com.stripe.android.CustomerSession.getInstance(CustomerSession.java:120)
       at com.stripe.android.view.PaymentFlowActivity.onCreate(PaymentFlowActivity.java:55)
       at android.app.Activity.performCreate(Activity.java:6679)
       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
       at android.app.ActivityThread.-wrap12(ActivityThread.java)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:154)
       at android.app.ActivityThread.main(ActivityThread.java:6119)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
       at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:107)

We've had many successful transactions since the last time we saw this in December and a few since (on a Nexus 6, Android 7.1.1, as it was reported) just to test. It only shows up in crashlytics, so I'm not sure under which conditions it's occurring, or how to reproduce it. I have a vague suspicion it might be related to some automation either in the google play store or elsewhere, that might be loading screens out of order or too quickly or something like that, but it's a wild guess in the dark. I have no evidence to support this and the google play store tests appear to have all passed (maybe there's a delay in reporting...?). It's infrequent enough for us to accept as "a thing that happens sometimes" but I figured you and posterity might be interested to know that it's still out there. Of course, resolving it would be ideal though, so let me know if you have any ideas or want more info. Thanks

Was this page helpful?
0 / 5 - 0 ratings

Related issues

danielgomezrico picture danielgomezrico  Â·  9Comments

OleksandrGrument picture OleksandrGrument  Â·  10Comments

dlambeth picture dlambeth  Â·  6Comments

ahqmrf picture ahqmrf  Â·  8Comments

danielgomezrico picture danielgomezrico  Â·  6Comments