We recently updated IAP in our app and we’re seeing lots of internal stacktraces with null ref exceptions (see below for stack traces)
The behaviour reported:
Some users are completing an IAP successfully and our backend is not receiving the request to validate it. Restarting the app also doesn’t cause the IAPs to get checked again or they are being processed and the request isn’t being sent to our backend.
The request not being sent to our backend is suspected to be a result of the exceptions being thrown.
Extra info: we’ve had working IAP within the game for 2 years and have not had this issue previously, the only change that was made was upgrading IAP from 2.1.0 to 2.2.4
Unity version: 2018.4.30f1
Note. The majority of purchases are still processing ok.
We believe the stacktraces below are causing the issues (captured via cloud diagnostics):
Stacktrace 1
Problem Report
Project: Ancients Reborn
Problem Id: 5faf0064
Crashes: 39
NullReferenceException: Object reference not set to an instance of an object.
Managed Stack Trace:
UnityEngine.Purchasing.Models.GooglePurchaseResult.FillPurchases (UnityEngine.AndroidJavaObject purchaseResult, UnityEngine.Purchasing.IGoogleCachedQuerySkuDetailsService cachedQuerySkuDetailsService) (at <00000000000000000000000000000000>:0)
UnityEngine.Purchasing.GoogleQueryPurchasesService.QueryPurchasesWithSkuType (System.String skuType) (at <00000000000000000000000000000000>:0)
UnityEngine.Purchasing.GoogleQueryPurchasesService.QueryPurchases (System.Action`1[T] onQueryPurchaseSucceed) (at <00000000000000000000000000000000>:0)
UnityEngine.Purchasing.QuerySkuDetailsService.ConsolidateOnSkuDetailsReceived (UnityEngine.AndroidJavaObject javaBillingResult, UnityEngine.AndroidJavaObject skuDetails, System.Action`1[T] onSkuDetailsResponse) (at <00000000000000000000000000000000>:0)
UnityEngine.Purchasing.QuerySkuDetailsService+<>c__DisplayClass16_0.<QuerySkuDetails>b__0 (UnityEngine.AndroidJavaObject billingResult, UnityEngine.AndroidJavaObject skuDetails) (at <00000000000000000000000000000000>:0)
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <00000000000000000000000000000000>:0)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <00000000000000000000000000000000>:0)
UnityEngine.AndroidJavaProxy.Invoke (System.String methodName, System.Object[] args) (at <00000000000000000000000000000000>:0)
UnityEngine._AndroidJNIHelper.InvokeJavaProxyMethod (UnityEngine.AndroidJavaProxy proxy, System.IntPtr jmethodName, System.IntPtr jargs) (at <00000000000000000000000000000000>:0)
Rethrow as TargetInvocationException: UnityEngine.Purchasing.SkuDetailsResponseListener.onSkuDetailsResponse(UnityEngine.AndroidJavaObject,UnityEngine.AndroidJavaObject)
UnityEngine.AndroidJavaProxy.Invoke (System.String methodName, System.Object[] args) (at <00000000000000000000000000000000>:0)
UnityEngine._AndroidJNIHelper.InvokeJavaProxyMethod (UnityEngine.AndroidJavaProxy proxy, System.IntPtr jmethodName, System.IntPtr jargs) (at <00000000000000000000000000000000>:0)
Stacktrace 2
Problem Report
Project: Ancients Reborn
Problem Id: a73e522a
Crashes: 27
NullReferenceException: Object reference not set to an instance of an object
Managed Stack Trace:
UnityEngine.Purchasing.Models.GooglePurchaseResult.FillPurchases (UnityEngine.AndroidJavaObject purchaseResult, UnityEngine.Purchasing.IGoogleCachedQuerySkuDetailsService cachedQuerySkuDetailsService) (at <00000000000000000000000000000000>:0)
UnityEngine.Purchasing.GoogleQueryPurchasesService.QueryPurchasesWithSkuType (System.String skuType) (at <00000000000000000000000000000000>:0)
UnityEngine.Purchasing.GoogleQueryPurchasesService.QueryPurchases (System.Action`1[T] onQueryPurchaseSucceed) (at <00000000000000000000000000000000>:0)
UnityEngine.Purchasing.Extension.UnityUtil.OnApplicationPause (System.Boolean paused) (at <00000000000000000000000000000000>:0)