Vizir / react-native-paypal

Native Paypal payment screen for React Native
MIT License
51 stars 15 forks source link

App crashes unexpectedly right after selecting pay. #4

Closed ardowz closed 8 years ago

ardowz commented 8 years ago

Any thoughts on why it crashes all of a sudden?

cartolari commented 8 years ago

Maybe the PayPal SDK is throwing some exception and this causes the app to crash. Does the exception occur after choosing PayPal or credit card? If yes which option did you choose? Also, could you please try to see the output of Logcat (run adb logcat) to check if any exception is being thrown? This may help us to trace the issue.

Thanks for reporting.

cartolari commented 8 years ago

Why did you close the issue, have you found the problem?

ardowz commented 8 years ago

I accidentally closed the issue, sorry about that. Let me get the logs for you

ardowz commented 8 years ago

Here is what i think is related to the crash:

I/MicroDetectionWrkImpl( 1124): Micro detection mode: 1.
D/PanelView( 4030): There is/are notification(s)
E/        ( 3070): BitTube(): close sendFd (116)
E/        ( 3070): BitTube(): close sendFd (120)
I/WindowState( 3569): WIN DEATH: Window{2e92899f u0 d0 com.studypoolmobile/com.paypal.android.sdk.payments.PaymentActivity}
D/ConnectivityService( 3569): ConnectivityService NetworkRequestInfo binderDied(NetworkRequest [ id=1998, legacyType=-1, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&NOT_VPN] ], android.os.BinderProxy@fb87f15)
D/ConnectivityService( 3569): releasing NetworkRequest NetworkRequest [ id=1998, legacyType=-1, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&NOT_VPN] ]
I/ActivityManager( 3569): Process com.studypoolmobile (pid 3151)(adj 13) has died(158,534)
D/libEGL  ( 3070): eglTerminate EGLDisplay = 0x7f9ea1e6a8
D/libEGL  ( 3070): eglTerminate EGLDisplay = 0x7f9ea1e6a8
D/libEGL  ( 3070): eglTerminate EGLDisplay = 0x7f9ea1e6a8
D/libEGL  ( 3070): eglTerminate EGLDisplay = 0x7f9ea1e6a8
E/ConnectivityService( 3569): RemoteException caught trying to send a callback msg for NetworkRequest [ id=1998, legacyType=-1, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&NOT_VPN] ]
W/ActivityManager( 3569): Scheduling restart of crashed service com.studypoolmobile/com.paypal.android.sdk.payments.PayPalService in 40486ms
W/InputDispatcher( 3569): channel ~ Consumer closed input channel or an error occurred.  events=0x9
E/InputDispatcher( 3569): channel ~ Channel is unrecoverably broken and will be disposed!
W/InputDispatcher( 3569): channel ~ Consumer closed input channel or an error occurred.  events=0x9
E/InputDispatcher( 3569): channel ~ Channel is unrecoverably broken and will be disposed!
W/InputDispatcher( 3569): channel ~ Consumer closed input channel or an error occurred.  events=0x9
E/InputDispatcher( 3569): channel ~ Channel is unrecoverably broken and will be disposed!
W/InputDispatcher( 3569): channel ~ Consumer closed input channel or an error occurred.  events=0x9
E/InputDispatcher( 3569): channel ~ Channel is unrecoverably broken and will be disposed!
I/EnterpriseSharedDevicePolicy( 3569): UID1000
D/SensorService( 3569): cleanupConnection - size : 2, ref : 0
E/        ( 3569): BitTube(): close sendFd (474)
W/InputDispatcher( 3569): Attempted to unregister already unregistered input channel
I/WindowState( 3569): WIN DEATH: Window{cd488fa u0 d0 com.studypoolmobile/com.paypal.android.sdk.payments.PaymentMethodActivity}
I/EnterpriseSharedDevicePolicy( 3569): UID1000
I/WindowState( 3569): WIN DEATH: Window{27abe12d u0 d0 Processing}
W/InputDispatcher( 3569): Attempted to unregister already unregistered input channel
I/SurfaceFlinger( 3070): id=9829 Removed Qrocessing (10/16)
I/SurfaceFlinger( 3070): id=9829 Removed Qrocessing (-2/16)
D/libEGL  ( 3070): eglTerminate EGLDisplay = 0x7fc3109d08
I/EnterpriseSharedDevicePolicy( 3569): UID1000
I/WindowState( 3569): WIN DEATH: Window{11d7dc9e u0 d0 com.studypoolmobile/com.paypal.android.sdk.payments.PaymentConfirmActivity}
ardowz commented 8 years ago

Heres a more relevant log:

While trying to use the paypal sdk Im getting these messages

Class not found when unmarshalling: com.paypal.android.sdk.payments.PayPalPayment
E/Parcel  ( 3569): java.lang.ClassNotFoundException: com.paypal.android.sdk.payments.PayPalPayment
E/Parcel  ( 3569):  at java.lang.Class.classForName(Native Method)
E/Parcel  ( 3569):  at java.lang.Class.forName(Class.java:309)
E/Parcel  ( 3569):  at java.lang.Class.forName(Class.java:273)
E/Parcel  ( 3569):  at android.os.Parcel.readParcelableCreator(Parcel.java:2281)
E/Parcel  ( 3569):  at android.os.Parcel.readParcelable(Parcel.java:2245)
E/Parcel  ( 3569):  at android.os.Parcel.readValue(Parcel.java:2152)
E/Parcel  ( 3569):  at android.os.Parcel.readArrayMapInternal(Parcel.java:2485)
E/Parcel  ( 3569):  at android.os.BaseBundle.unparcel(BaseBundle.java:221)
E/Parcel  ( 3569):  at android.os.BaseBundle.getString(BaseBundle.java:918)
E/Parcel  ( 3569):  at android.content.Intent.getStringExtra(Intent.java:5813)
E/Parcel  ( 3569):  at com.android.server.am.ActivityStackSupervisor.startActivityLocked(ActivityStackSupervisor.java:2480)
E/Parcel  ( 3569):  at com.android.server.am.ActivityStackSupervisor.startActivityMayWait(ActivityStackSupervisor.java:1961)
E/Parcel  ( 3569):  at com.android.server.am.ActivityManagerService.startActivityAsUser(ActivityManagerService.java:5907)
E/Parcel  ( 3569):  at com.android.server.am.ActivityManagerService.startActivity(ActivityManagerService.java:5683)
E/Parcel  ( 3569):  at android.app.ActivityManagerNative.onTransact(ActivityManagerNative.java:142)
E/Parcel  ( 3569):  at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:3843)
E/Parcel  ( 3569):  at android.os.Binder.execTransact(Binder.java:461)
E/Parcel  ( 3569): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.paypal.android.sdk.payments.PayPalPayment" on path: DexPathList[[directory "."],nativeLibraryDirectories=[/vendor/lib64, /system/lib64]]
E/Parcel  ( 3569):  at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
E/Parcel  ( 3569):  at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
E/Parcel  ( 3569):  at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
E/Parcel  ( 3569):  ... 17 more
E/Parcel  ( 3569):  Suppressed: java.lang.ClassNotFoundException: com.paypal.android.sdk.payments.PayPalPayment
E/Parcel  ( 3569):      at java.lang.Class.classForName(Native Method)
E/Parcel  ( 3569):      at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
E/Parcel  ( 3569):      at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
E/Parcel  ( 3569):      at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
E/Parcel  ( 3569):      ... 18 more
E/Parcel  ( 3569):  Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
E/Parcel  ( 3569): Class not found when unmarshalling: com.paypal.android.sdk.payments.PayPalPayment
E/Parcel  ( 3569): java.lang.ClassNotFoundException: com.paypal.android.sdk.payments.PayPalPayment
E/Parcel  ( 3569):  at java.lang.Class.classForName(Native Method)
E/Parcel  ( 3569):  at java.lang.Class.forName(Class.java:309)
E/Parcel  ( 3569):  at java.lang.Class.forName(Class.java:273)
E/Parcel  ( 3569):  at android.os.Parcel.readParcelableCreator(Parcel.java:2281)
E/Parcel  ( 3569):  at android.os.Parcel.readParcelable(Parcel.java:2245)
E/Parcel  ( 3569):  at android.os.Parcel.readValue(Parcel.java:2152)
E/Parcel  ( 3569):  at android.os.Parcel.readArrayMapInternal(Parcel.java:2485)
E/Parcel  ( 3569):  at android.os.BaseBundle.unparcel(BaseBundle.java:221)
E/Parcel  ( 3569):  at android.os.BaseBundle.getString(BaseBundle.java:918)
E/Parcel  ( 3569):  at android.content.Intent.getStringExtra(Intent.java:5813)
E/Parcel  ( 3569):  at com.android.server.am.ActivityStackSupervisor.startActivityLocked(ActivityStackSupervisor.java:2480)
E/Parcel  ( 3569):  at com.android.server.am.ActivityStackSupervisor.startActivityMayWait(ActivityStackSupervisor.java:1961)
E/Parcel  ( 3569):  at com.android.server.am.ActivityManagerService.startActivityAsUser(ActivityManagerService.java:5907)
E/Parcel  ( 3569):  at com.android.server.am.ActivityManagerService.startActivity(ActivityManagerService.java:5683)
E/Parcel  ( 3569):  at android.app.ActivityManagerNative.onTransact(ActivityManagerNative.java:142)
E/Parcel  ( 3569):  at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:3843)
E/Parcel  ( 3569):  at android.os.Binder.execTransact(Binder.java:461)
E/Parcel  ( 3569): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.paypal.android.sdk.payments.PayPalPayment" on path: DexPathList[[directory "."],nativeLibraryDirectories=[/vendor/lib64, /system/lib64]]
E/Parcel  ( 3569):  at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
E/Parcel  ( 3569):  at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
E/Parcel  ( 3569):  at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
E/Parcel  ( 3569):  ... 17 more
E/Parcel  ( 3569):  Suppressed: java.lang.ClassNotFoundException: com.paypal.android.sdk.payments.PayPalPayment
E/Parcel  ( 3569):      at java.lang.Class.classForName(Native Method)
E/Parcel  ( 3569):      at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
E/Parcel  ( 3569):      at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
E/Parcel  ( 3569):      at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
E/Parcel  ( 3569):      ... 18 more
E/Parcel  ( 3569):  Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available

This is when the app crashes (so I'm getting -1 as result)

E/AndroidRuntime(17673): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=9, result=-1, data=Intent { (has extras) }} to activity {com.studypoolmobile/com.studypoolmobile.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void br.com.vizir.rn.paypal.PayPalPackage.handleActivityResult(int, int, android.content.Intent)' on a null object reference
E/AndroidRuntime(17673):    at android.app.ActivityThread.deliverResults(ActivityThread.java:4717)
E/AndroidRuntime(17673):    at android.app.ActivityThread.handleSendResult(ActivityThread.java:4760)
E/AndroidRuntime(17673):    at android.app.ActivityThread.access$1500(ActivityThread.java:197)
E/AndroidRuntime(17673):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1736)
E/AndroidRuntime(17673):    at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime(17673):    at android.os.Looper.loop(Looper.java:145)
E/AndroidRuntime(17673):    at android.app.ActivityThread.main(ActivityThread.java:6897)
E/AndroidRuntime(17673):    at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(17673):    at java.lang.reflect.Method.invoke(Method.java:372)
E/AndroidRuntime(17673):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
E/AndroidRuntime(17673):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
E/AndroidRuntime(17673): Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void br.com.vizir.rn.paypal.PayPalPackage.handleActivityResult(int, int, android.content.Intent)' on a null object reference
E/AndroidRuntime(17673):    at com.studypoolmobile.MainActivity.onActivityResult(MainActivity.java:93)
E/AndroidRuntime(17673):    at android.app.Activity.dispatchActivityResult(Activity.java:6808)
E/AndroidRuntime(17673):    at android.app.ActivityThread.deliverResults(ActivityThread.java:4713)
E/AndroidRuntime(17673):    ... 10 more

I'm currently trying to figure out if this might be related to: https://github.com/paypal/PayPal-Android-SDK/issues/128

cartolari commented 8 years ago

Could you check if in the version 1.0.2 the error happens? We've upgraded the react-native and the PayPal sdk in the 1.0.3.

ardowz commented 8 years ago

Im currently using the 1.0.3 as well as RN 19.

cartolari commented 8 years ago

OK, but if you lock the npm package to 1.0.2 would the issue still happens? Just to be sure if it was our upgrade that may have caused it.

ardowz commented 8 years ago

Yeah it still happens. I actually tried it on the 1.0.2 before moving up to 1.0.3 but still not working

ardowz commented 8 years ago

I tried creating a vanilla project just to test it out. I ran it in both 0.18 and 0.19. Both version had the same issues. Is there other things I should consider?

cartolari commented 8 years ago

I'll give it a more careful look in the weekend. Since you've built a vanilla project with the minimum to simulate the bug could you upload it to a repository?

ardowz commented 8 years ago

Sure, the repo is available here: https://github.com/ardowz/react-native-paypal-vanilla-test I also have the branch 0.19 available so theres 0.18 and 0.19.

cartolari commented 8 years ago

Found the bug, The payPalPackage was never initialized in your sample, so when the onActivityResult method was invoked it tried to call the method handleActivityResult on a null reference. By changing the the method getPackages in your sample as follows solves the issue for me. Can you confirm?

@Override
protected List<ReactPackage> getPackages() {
    payPalPackage = new PayPalPackage(this, PAY_PAL_REQUEST_ID); // This should fix  the issue
    return Arrays.<ReactPackage>asList(new MainReactPackage(), payPalPackage);
}
ardowz commented 8 years ago

Omg, thats exactly how it fixed it!

So it doesn't work if the new PayPalPackage is included in the in the list.

Thank you so much!