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

java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.SharedPreferences android.content.Context.getSharedPreferences(java.lang.String, int)' on a null object reference #400

Open davepaiva opened 2 years ago

davepaiva commented 2 years ago

Description

Crashlytics report showing fatal errors related to Razorpay on the android platform in production: com.razorpay.SharedPreferenceUtil.getPrivatePrefs As per #

Razorpay Package Version :

"react-native-razorpay": "^2.2.7"

Java and Gradle Version (android) :

openjdk version "1.8.0_272" OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_272-b10) OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.272-b10, mixed mode)

gradle:3.6.3

What happened:

We got the following crash event on firebase:

Fatal Exception: java.lang.RuntimeException: Unable to resume activity {com.MyApp.MainActivity}: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=62442, result=1, data=Intent { (has extras) }} to activity {com.MyApp.MainActivity: 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 android.app.ActivityThread.performResumeActivity(ActivityThread.java:4811)
       at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4849)
       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:261)
       at android.app.ActivityThread.main(ActivityThread.java:8279)
       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)
Caused by java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=62442, result=1, data=Intent { (has extras) }} to activity {com.MyApp.MainActivity}: 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 android.app.ActivityThread.deliverResults(ActivityThread.java:5428)
       at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4794)
       at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4849)
       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:261)
       at android.app.ActivityThread.main(ActivityThread.java:8279)
       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)
vivekshindhe commented 2 years ago

Hey @davepaiva We have released a new version of react-native-razorpay. Please check if you are able to reproduce this issue with that version. The latest version is 2.2.9.

davepaiva commented 2 years ago

Thanks for the response @vivekshindhe . I will update the package and check it from my end

vivekshindhe commented 2 years ago

@davepaiva are you still facing the issue?

harendrasaini01 commented 1 year ago

@vivekshindhe my latest version of razorpay is "react-native-razorpay": "^2.3.0" but I am facing the issue still.