Update to 2.2.2, have some NullReferenceException

Hi,
I update Unity IAP to 2.2.2 recently and without any code changing of my IAP logic.

But when I check the cloud diagnostics, I found some nullreferenceexception.

May I know whether it is a issue?

Call stack is

UnityEngine.Purchasing.Models.GooglePurchaseResult.FillPurchases (UnityEngine.AndroidJavaObject purchaseResult, Stores.IGoogleCachedQuerySkuDetailsService cachedQuerySkuDetailsService) (at <00000000000000000000000000000000>:0)
UnityEngine.Purchasing.GoogleQueryPurchasesService.QueryPurchasesWithSkuType (System.String skuType) (at <00000000000000000000000000000000>:0)
UnityEngine.Purchasing.GoogleQueryPurchasesService.QueryPurchases (System.Action1[T] onQueryPurchaseSucceed) (at <00000000000000000000000000000000>:0) System.Action1[T].Invoke (T obj) (at <00000000000000000000000000000000>:0)
UnityEngine.Purchasing.Extension.UnityUtil.OnApplicationPause (System.Boolean paused) (at <00000000000000000000000000000000>:0)

Same issue here after the update

Is this during IAP initialization or during a purchase?

Hi
According to the callstack, It happens not in init or purchase.
I check user’s subsricption infomation every hour in OnApplicationPause when pause is false, in case user’s subscription changed.
it should happened when I query the subscription info.

I checked the cloud diagnostics again.
I also found that it also happened when init failed.
Callstack is
UnityEngine.Purchasing.Models.GooglePurchaseResult.FillPurchases (UnityEngine.AndroidJavaObject purchaseResult, Stores.IGoogleCachedQuerySkuDetailsService cachedQuerySkuDetailsService) (at <00000000000000000000000000000000>:0)
UnityEngine.Purchasing.GoogleQueryPurchasesService.QueryPurchasesWithSkuType (System.String skuType) (at <00000000000000000000000000000000>:0)
UnityEngine.Purchasing.GoogleQueryPurchasesService.QueryPurchases (System.Action1[T] onQueryPurchaseSucceed) (at <00000000000000000000000000000000>:0) System.Action1[T].Invoke (T obj) (at <00000000000000000000000000000000>:0)
System.Action1[T].Invoke (T obj) (at <00000000000000000000000000000000>:0) UnityEngine.Purchasing.QuerySkuDetailsService.ConsolidateOnSkuDetailsReceived (UnityEngine.AndroidJavaObject javaBillingResult, UnityEngine.AndroidJavaObject skuDetails, System.Action1[T] onSkuDetailsResponse) (at <00000000000000000000000000000000>:0)
UnityEngine.Purchasing.QuerySkuDetailsService+<>c__DisplayClass16_0.b__0 (UnityEngine.AndroidJavaObject billingResult, UnityEngine.AndroidJavaObject skuDetails) (at <00000000000000000000000000000000>:0)
System.Action`2[T1,T2].Invoke (T1 arg1, T2 arg2) (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)

log is :

In-App Purchasing OnInitializeFailed. InitializationFailureReason:NoProductsAvailable

my Unity IAP version 2.2.2, In-APP purchasing package 2.2.1
unity version Unity 2019 LTS 4.15

Does your app crash when this happens? Otherwise, you’ll need to ensure that your products are available. Please provide the device logs, they will provide more information as to why the products are not available. How To - Capturing Device Logs on Android

same problem here, here is the device log:

12-06 13:31:13.338: E/Unity(15994): NullReferenceException: Object reference not set to an instance of an object.
12-06 13:31:13.338: E/Unity(15994): at UnityEngine.Purchasing.Models.GooglePurchaseResult.FillPurchases (UnityEngine.AndroidJavaObject purchaseResult, Stores.IGoogleCachedQuerySkuDetailsService cachedQuerySkuDetailsService) [0x00000] in <00000000000000000000000000000000>:0 
12-06 13:31:13.338: E/Unity(15994): at UnityEngine.Purchasing.GoogleQueryPurchasesService.QueryPurchasesWithSkuType (System.String skuType) [0x00000] in <00000000000000000000000000000000>:0 
12-06 13:31:13.338: E/Unity(15994): at UnityEngine.Purchasing.GoogleQueryPurchasesService.QueryPurchases (System.Action`1[T] onQueryPurchaseSucceed) [0x00000] in <00000000000000000000000000000000>:0 
12-06 13:31:13.338: E/Unity(15994): at System.Action`1[T].Invoke (T obj) [0x00000] in <00000000000000000000000000000000>:0 
12-06 13:31:13.338: E/Unity(15994): at UnityEngine.Purchasing.QuerySkuDetailsService.ConsolidateOnSkuDetailsReceived (UnityEngine.AndroidJavaObject javaBillingResult, UnityEngine.AndroidJavaObject skuDetails, System.Action`1[T] onSkuDe

same problem - log from crashlytics - Unity :
#1

Non-fatal Exception: java.lang.Exception: NullReferenceException : Object reference not set to an instance of an object.
at UnityEngine.Purchasing.Models.GooglePurchaseResult.FillPurchases(UnityEngine.Purchasing.Models.GooglePurchaseResult)
at UnityEngine.Purchasing.GoogleQueryPurchasesService.QueryPurchasesWithSkuType(UnityEngine.Purchasing.GoogleQueryPurchasesService)
at UnityEngine.Purchasing.GoogleQueryPurchasesService.QueryPurchases(UnityEngine.Purchasing.GoogleQueryPurchasesService)
at System.Action1[T].Invoke(System.Action1[T])
at UnityEngine.Purchasing.Extension.UnityUtil.OnApplicationPause(UnityEngine.Purchasing.Extension.UnityUtil)

#2

Non-fatal Exception: java.lang.Exception: NullReferenceException : Object reference not set to an instance of an object.
at UnityEngine.Purchasing.Models.GooglePurchaseResult.FillPurchases(UnityEngine.Purchasing.Models.GooglePurchaseResult)
at UnityEngine.Purchasing.GoogleQueryPurchasesService.QueryPurchasesWithSkuType(UnityEngine.Purchasing.GoogleQueryPurchasesService)
at UnityEngine.Purchasing.GoogleQueryPurchasesService+<>c__DisplayClass3_0.b__0(UnityEngine.Purchasing.GoogleQueryPurchasesService+<>c__DisplayClass3_0)
at System.Action1[T].Invoke(System.Action1[T])
at System.Action1[T].Invoke(System.Action1[T])
at UnityEngine.Purchasing.Extension.UnityUtil.OnApplicationPause(UnityEngine.Purchasing.Extension.UnityUtil)

Please provide steps to reproduce using IAP 2.2.3 ideally using the Sample IAP project here Sample IAP Project

That’s the problem. We can’t reproduce the bug on any of our devices during QA. Those crashes are from Firebase Crashlytics of a released game.

Unfortunately there is no action we could take in that case. You would want to look for any specifics around the crash reports, like the same phone type, country, etc. Otherwise you’ll want to publish with Unity 2.2.4 (or the most current version, they are coming out fast) and see if it helps.

The problem started appearing in crashlytics when I upgraded the unity package from 2.1.1 to 2.2.0.
The current build is live with version 2.2.4. It still happens.
Thinking about reverting back.

Please let us know if you find out any additional details from the crash reports, as mentioned. Previous releases are here https://discussions.unity.com/t/632966

Hi,
We have the same problem - 20+ cases on Crashlytics (android, different devices, different android versions, Unity IAP 2.2.4). Problem starts from 2.2.x (version 2.1.1 was ok).

We are checking. If you can find steps to reproduce, it would be appreciated. But we will inspect the code regardless.

Jeff, I have a project where I can stably reproduce this case. I’d like to strip down all assets/code, pack it and send it to you. Should I use PM here or would you like me to send it via e-mail?

Just the written steps should suffice, otherwise I recommend that we always test with the Sample IAP Project here so we are on the same page https://discussions.unity.com/t/700293

Okay, so I sent you my logs in a PM

I received the logs, but I need steps to reproduce, thanks. I do see “Please provide a valid SKU type” in the logs. What’s different between your project and the Sample project? Please test with IAP 2.2.4

Please provide your project, unless you can identify any differences between the Sample IAP project. Please DM me