jamesmontemagno / InAppBillingPlugin

Cross-platform In App Billing Plugin for .NET
MIT License
651 stars 152 forks source link

NullReferenceException in HandleActivityResult #153

Closed BioTurboNick closed 3 years ago

BioTurboNick commented 6 years ago

Bug Information

Version Number of Plugin: 1.2.5 Device Tested On: Android 5.0 (Thai) Version of VS: 15.7.1 Version of Xamarin: 3.0.0.446417

Steps to reproduce the Behavior

Unknown, crash report from user. Based on code + event data from AppCenter, occurs when PurchaseAsync() called.

Expected Behavior

No crash

Actual Behavior

Crash

Stack trace: https://gist.github.com/BioTurboNick/f9d5c89109a2e8cdbb9f130688248528

BioTurboNick commented 6 years ago

May be related to this 2-year-old report? https://bugzilla.xamarin.com/show_bug.cgi?id=49230

BioTurboNick commented 6 years ago

Looking at the code, there aren't many opportunities for a null. Based on the code, I see null guards for tcsPurchase on lines 515 and 535, but not after. Unless it's possible for tcsPurchase to be non-null but its Task property to be null?

BioTurboNick commented 6 years ago

Just received another of these crashes on Plugin version 2.0.0. Galaxy S8 running Android 8.0 with English language.

Ptytz commented 5 years ago

Have the same report from AppCenter

InAppBillingImplementation.HandleActivityResult (System.Int32 requestCode, Android.App.Result resultCode, Android.Content.Intent data)
System.NullReferenceException: Object reference not set to an instance of an object

Device Redmi 4X OS Android 7.1.2 Version Number of Plugin: 2.0.0

thisisthekap commented 5 years ago

@jamesmontemagno We also experienced this issue on Xiaomi Redmi Note 4 with Android 7.0. It was reported to us via AppCenter.

I tried to reproduce the issue using a real Xiaomi Redmi Note 4 at saucelabs, but without success. Everything worked as expected during my test.

tipa commented 5 years ago

Seeing this issue reported via AppCenter as well, using v2.0.0

masterwok commented 5 years ago

I'm also seeing this exception on Android 8.0.0 and 8.1.0 using version 2.0.0. Below is the stack trace:

Fatal Exception: android.runtime.JavaProxyThrowable: System.NullReferenceException: Object reference not set to an instance of an object
  at Plugin.InAppBilling.InAppBillingImplementation.HandleActivityResult (System.Int32 requestCode, Android.App.Result resultCode, Android.Content.Intent data) [0x000bc] in <1c86ecc2b41d4594a8d40ec3a18782af>:0 
  at ShrimpleSearch.Settings.Activities.SettingsActivity.OnActivityResult (System.Int32 requestCode, Android.App.Result resultCode, Android.Content.Intent data) [0x00009] in <0686187fda26485da20d219388fa83cd>:0 
  at Android.App.Activity.n_OnActivityResult_IILandroid_content_Intent_ (System.IntPtr jnienv, System.IntPtr native__this, System.Int32 requestCode, System.Int32 native_resultCode, System.IntPtr native_data) [0x00014] in <73f2895fa7c5473ea3b8cc7efc638e31>:0 
  at (wrapper dynamic-method) System.Object.21(intptr,intptr,int,int,intptr)
       at md5447db9725d2b86052e13086ec20c3a93.SettingsActivity.n_onActivityResult(SettingsActivity.java)
       at md5447db9725d2b86052e13086ec20c3a93.SettingsActivity.onActivityResult + 84(SettingsActivity.java:84)
       at android.app.Activity.dispatchActivityResult + 7255(Activity.java:7255)
       at android.app.ActivityThread.deliverResults + 4506(ActivityThread.java:4506)
       at android.app.ActivityThread.performResumeActivity + 3780(ActivityThread.java:3780)
       at android.app.ActivityThread.handleResumeActivity + 3848(ActivityThread.java:3848)
       at android.app.ActivityThread.handleLaunchActivity + 3057(ActivityThread.java:3057)
       at android.app.ActivityThread.-wrap11(Unknown Source)
       at android.app.ActivityThread$H.handleMessage + 1701(ActivityThread.java:1701)
       at android.os.Handler.dispatchMessage + 105(Handler.java:105)
       at android.os.Looper.loop + 164(Looper.java:164)
       at android.app.ActivityThread.main + 6797(ActivityThread.java:6797)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.Zygote$MethodAndArgsCaller.run + 240(Zygote.java:240)
       at com.android.internal.os.ZygoteInit.main + 772(ZygoteInit.java:772)
pro777s commented 4 years ago

Same mistake. Android 6.0 using version 2.0.0. HResult : -2146233088. System.Exception: CurrentDomainOnUnhandledException ---> System.NullReferenceException: Object reference not set to an instance of an object at Plugin.InAppBilling.InAppBillingImplementation.HandleActivityResult (System.Int32 requestCode, Android.App.Result resultCode, Android.Content.Intent data) [0x000bc] in <8dea3f2d2df9415eaf4b83abb8288124>:0 at Android.App.Activity.n_OnActivityResult_IILandroid_contentIntent (System.IntPtr jnienv, System.IntPtr native__this, System.Int32 requestCode, System.Int32 native_resultCode, System.IntPtr native_data) [0x00014] in :0 at (wrapper dynamic-method) System.Object.15(intptr,intptr,int,int,intptr) --- End of inner exception stack trace ---

BioTurboNick commented 4 years ago

Received another crash report of this same kind.

It looks like a fix was been integrated 7 months ago, but the last release was over a year ago.

@jamesmontemagno - could you please make a release?

thisisthekap commented 4 years ago

@jamesmontemagno Would it be feasible to publish a new release? :)

thisisthekap commented 4 years ago

@jamesmontemagno Would it be feasible to publish a new release? :)

BioTurboNick commented 3 years ago

Closing as this is likely rendered moot by v4.