stripe-android
stripe-android copied to clipboard
[BUG] Getting ANR on Android 11
Summary
Started to get firebase ANRs while using payments with stipe and it's not form my side.
main (runnable): tid=1 systid=10243
at com.stripe.android.PaymentConfiguration.
Android version
android 11
Impacted devices
Device Brand:OPPO Model:F11 Pro Operating System Version:Android 11 ANR Date:Oct 16, 2022, 11:30:38 AM App version:V5.3.58 (11112719)
Installation method
Through a gradle dependency
Dependency Versions
implementation 'com.stripe:stripe-android:20.15.0'
SDK classes
PaymentConfiguration
Hi @MoustafaElsaghier 👋 Can you provide a small sample application for us to reproduce the issue?
Unfortunately, i don't have the specific scenario for reproduce the issue. As i mentioned earlier it's delivered to the crashlytics in firebase
On Mon, Oct 17, 2022, 5:25 PM Till Hellmund @.***> wrote:
Hi @MoustafaElsaghier https://github.com/MoustafaElsaghier 👋 Can you provide a small sample application for us to reproduce the issue?
— Reply to this email directly, view it on GitHub https://github.com/stripe/stripe-android/issues/5711#issuecomment-1281050301, or unsubscribe https://github.com/notifications/unsubscribe-auth/AELECU4PVT5JMWHKXKNNUT3WDVVYNANCNFSM6AAAAAARGI7JHE . You are receiving this because you were mentioned.Message ID: @.***>
Can you share a code snippet of what’s happening in your Application class?
call this function in onCreate of Application class private fun setupStripe() { if (BuildConfig.FLAVOR == "staging") { PaymentConfiguration.init(applicationContext, getStripeTestKey()) } else { PaymentConfiguration.init(applicationContext, getStripeLiveKey()) } }
Moustafa EL-Saghier Android Developer
+2 01113970586 <+2+01113970586> | +2 01017509660 <+2+01017509660> | @.** @.**>
Gesr EL-Suez, Cairo
[image: App Social Buttons Image] https://www.linkedin.com/in/moustafaelsaghier/
On Mon, 17 Oct 2022 at 18:55, Till Hellmund @.***> wrote:
Can you share a code snippet of what’s happening in your Application class?
— Reply to this email directly, view it on GitHub https://github.com/stripe/stripe-android/issues/5711#issuecomment-1281170055, or unsubscribe https://github.com/notifications/unsubscribe-auth/AELECU5ODOFMALEE4ERVDMDWDWAJ5ANCNFSM6AAAAAARGI7JHE . You are receiving this because you were mentioned.Message ID: @.***>
I took a closer look at what’s happening in our PaymentConfiguration.init(), and we’re actually causing a DiskReadViolation by accessing SharedPreferences.
If you want to prevent the ANR issues for now, you could move the initialization to a background thread. Just make sure that you’re not requiring PaymentConfiguration immediately afterwards.
class ExampleApplication : Application() {
override fun onCreate() {
super.onCreate()
val executor = Executors.newSingleThreadExecutor()
executor.execute {
PaymentConfiguration.init(this, publishableKey)
}
}
}
I’ll bring this up with our team and see how we can avoid the need for this workaround. Does this work for you?
Thank you I'll do it for now
On Thu, Oct 20, 2022, 6:16 PM Till Hellmund @.***> wrote:
I took a closer look at what’s happening in our PaymentConfiguration.init(), and we’re actually causing a DiskReadViolation by accessing SharedPreferences.
If you want to prevent the ANR issues for now, you could move the initialization to a background thread. Just make sure that you’re not requiring PaymentConfiguration immediately afterwards.
class ExampleApplication : Application() {
override fun onCreate() { super.onCreate() val executor = Executors.newSingleThreadExecutor() executor.execute { PaymentConfiguration.init(this, publishableKey) } }}
I’ll bring this up with our team and see how we can avoid the need for this workaround. Does this work for you?
— Reply to this email directly, view it on GitHub https://github.com/stripe/stripe-android/issues/5711#issuecomment-1285823686, or unsubscribe https://github.com/notifications/unsubscribe-auth/AELECU4S6COWCDDU2UO455TWEFV4NANCNFSM6AAAAAARGI7JHE . You are receiving this because you were mentioned.Message ID: @.***>