Bug 49230 - NullReferenceException in Xamarin.InAppBilling.InAppBillingHandler.HandleActivityResult
Summary: NullReferenceException in Xamarin.InAppBilling.InAppBillingHandler.HandleActi...
Status: NEW
Alias: None
Product: Components
Classification: Xamarin
Component: Xamarin Components ()
Version: N/A
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bill Holmes
Depends on:
Reported: 2016-12-07 14:39 UTC by John Hardman
Modified: 2016-12-07 14:44 UTC (History)
2 users (show)

Tags: Android NullReferenceException InAppBilling HandleActivityResult
Is this bug a regression?: ---
Last known good build:

Screenshot showing debugger (73.50 KB, image/png)
2016-12-07 14:39 UTC, John Hardman

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report for Bug 49230 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:

Description John Hardman 2016-12-07 14:39:15 UTC
Created attachment 18811 [details]
Screenshot showing debugger

When using the Xamarin.InAppBilling component with either of the two test products ReservedTestProductIDs.Canceled or ReservedTestProductIDs.Refunded, buying the product results in BillingHandler_InAppBillingProcessingError being called, with the message argument containing details of an exception within Xamarin.InAppBilling.InAppBillingHandler.HandleActivityResult

The message starts:
"Error Decoding Returned Packet Information: System.NullReferenceException: Object reference not set to an instance of an object.\n  at Xamarin.InAppBilling.InAppBillingHandler.HandleActivityResult (System.Int32 requestCode, Android.App.Result resultCode, Android.Content.Intent data)"

The stack trace at the point my code is passed this exception is as follows:

>	0x1A in MyAppAndroid.InAppPurchaseService.BillingHandler_InAppBillingProcessingError at G:\tfs\MyApp\ProjectMarvinPrototype\MyApp.Android\Dependency Services\InAppPurchaseServiceAndroid.cs:141,17	C#
 	0x38 in System.Runtime.CompilerServices.AsyncVoidMethodBuilder.Start<MyAppAndroid.InAppPurchaseService.<BillingHandler_InAppBillingProcessingError>d__20> at /Users/builder/data/lanes/3511/77cb8568/source/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:84,-1	C#
 	0x31 in MyAppAndroid.InAppPurchaseService.BillingHandler_InAppBillingProcessingError	C#
 	0x12 in Xamarin.InAppBilling.InAppBillingHandler.RaiseInAppBillingProcessingError	C#
 	0x15B in Xamarin.InAppBilling.InAppBillingHandler.HandleActivityResult	C#
 	0xE7 in MyAppAndroid.MainActivity.OnActivityResult at G:\tfs\MyApp\ProjectMarvinPrototype\MyApp.Android\AndroidActivities\MainActivity.cs:79,25	C#
 	0x38 in System.Runtime.CompilerServices.AsyncVoidMethodBuilder.Start<MyAppAndroid.MainActivity.<OnActivityResult>d__8> at /Users/builder/data/lanes/3511/77cb8568/source/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:84,-1	C#
 	0x3F in MyAppAndroid.MainActivity.OnActivityResult	C#
 	0x18 in Android.App.Activity.n_OnActivityResult_IILandroid_content_Intent_ at /Users/builder/data/lanes/3511/ce955cc0/source/monodroid/src/Mono.Android/platforms/android-24/src/generated/Android.App.Activity.cs:2274,4	C#
 	0x23 in object.8636cc33-2d19-4937-b0d6-ff6c9f748d01	C#

I am attaching a screenshot of the debugger, showing values in OnActivityResult.

Note that multiple people have mentioned this on the Xamarin.Forums at https://forums.xamarin.com/discussion/12023/crash-when-using-xamarin-inappbilling/p2
although I see no bug raised (hence me raising it now).
Comment 1 John Hardman 2016-12-07 14:44:18 UTC
Is the source code for the Xamarin.InAppBilling component open-source? If so, where is it located?