razorpay / react-native-razorpay

React Native wrapper for Razorpay's mobile SDKs
https://www.npmjs.com/package/react-native-razorpay
MIT License
125 stars 107 forks source link

Razorpay crash - SharedPreferenceUtil.java line 2 reported in Firebase crashlytics #383

Closed Cshayan closed 2 years ago

Cshayan commented 2 years ago

Description

Hi, I am seeing some crashes related to Razorpay in Firebase crashlytics. Though it is not reproducible from my end, but production users are facing the crash. Attaching the logs from the crash below -

SharedPreferenceUtil.java line 2
com.razorpay.SharedPreferenceUtil.getPrivatePrefs

Provided the stack trace below (in What happened section) -

Razorpay Package Version :

"react-native-razorpay": "2.2.2"

Xcode Version (iOS) :

Version 12.5.1 (12E507)

Razorpay-pod version (iOS) :

razorpay-pod (1.1.14)

Java and Gradle Version (android) :

Java version - 1.8.0_292 Gradle version - 6.7.1

What you did:

Found the crash logs in firebase crashlytics.

What happened:

Stack Trace -

Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.SharedPreferences android.content.Context.getSharedPreferences(java.lang.String, int)' on a null object reference
       at com.razorpay.SharedPreferenceUtil.getPrivatePrefs(SharedPreferenceUtil.java:2)
       at com.razorpay.CheckoutUtils.getUserContact(CheckoutUtils.java:1)
       at com.razorpay.Checkout.createPaymentData(Checkout.java:2)
       at com.razorpay.Checkout.handleActivityResult(Checkout.java:3)
       at com.razorpay.rn.RazorpayModule.onActivityResult(RazorpayModule.java:2)
       at com.razorpay.rn.RazorpayModule.onActivityResult(RazorpayModule.java:1)
       at com.facebook.react.bridge.ReactContext.onActivityResult(ReactContext.java:2)
       at com.facebook.react.m.F(ReactInstanceManager.java:2)
       at com.facebook.react.l.g(ReactDelegate.java:4)
       at com.facebook.react.i.k(ReactActivityDelegate.java:1)
       at com.facebook.react.h.onActivityResult(ReactActivity.java:1)
       at com.hrxmobileapp.MainActivity.onActivityResult(MainActivity.java:1)
       at android.app.Activity.dispatchActivityResult(Activity.java:8469)
       at android.app.ActivityThread.deliverResults(ActivityThread.java:5411)
       at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4800)
       at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4855)
       at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:52)
       at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176)
       at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2345)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loop(Looper.java:264)
       at android.app.ActivityThread.main(ActivityThread.java:8282)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:632)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1049)

Steps To Reproduce

Provide a detailed list of steps that reproduce the issue.

Not reproducible from my dev end, but seeing those crashes happening for production users in crashlytics.

Suggested solution:

Code example, screenshot, or link to a repository:

Please provide a link to a repository on GitHub, or provide a minimal code example that reproduces the problem. You may provide a screenshot of the application if you think it is relevant to your bug report. Here are some tips for providing a minimal example: https://stackoverflow.com/help/mcve

vivekshindhe commented 2 years ago

@Cshayan this has been resolved. Please update to the latest version and this error should not occur. Thank you. closing the ticket.

aj3012 commented 2 years ago

@vivekshindhe - what is the latest version that you are referring to? The last version that was released was way back in June 2021. Am I missing something?

Facing the same issue on a production app.