Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Update to 2.2.2, have some NullReferenceException

Discussion in 'Unity IAP' started by umiringo73, Nov 27, 2020.

  1. umiringo73

    umiringo73

    Joined:
    Apr 18, 2017
    Posts:
    13
    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.Action`1[T] onQueryPurchaseSucceed) (at <00000000000000000000000000000000>:0)
    System.Action`1[T].Invoke (T obj) (at <00000000000000000000000000000000>:0)
    UnityEngine.Purchasing.Extension.UnityUtil.OnApplicationPause (System.Boolean paused) (at <00000000000000000000000000000000>:0)
     
  2. redeev

    redeev

    Joined:
    Mar 15, 2015
    Posts:
    17
    Same issue here after the update
     
  3. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Is this during IAP initialization or during a purchase?
     
  4. umiringo73

    umiringo73

    Joined:
    Apr 18, 2017
    Posts:
    13
    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.
     
  5. umiringo73

    umiringo73

    Joined:
    Apr 18, 2017
    Posts:
    13
    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.Action`1[T] onQueryPurchaseSucceed) (at <00000000000000000000000000000000>:0)
    System.Action`1[T].Invoke (T obj) (at <00000000000000000000000000000000>:0)
    System.Action`1[T].Invoke (T obj) (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.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
     
  6. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
  7. DiceAndThrone

    DiceAndThrone

    Joined:
    Nov 9, 2020
    Posts:
    1
    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
     
  8. vidra

    vidra

    Joined:
    Jun 8, 2014
    Posts:
    7
    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.Action`1[T].Invoke(System.Action`1[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.<QueryPurchases>b__0(UnityEngine.Purchasing.GoogleQueryPurchasesService+<>c__DisplayClass3_0)
    at System.Action`1[T].Invoke(System.Action`1[T])
    at System.Action`1[T].Invoke(System.Action`1[T])
    at UnityEngine.Purchasing.Extension.UnityUtil.OnApplicationPause(UnityEngine.Purchasing.Extension.UnityUtil)
     
    Last edited: Dec 7, 2020
  9. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
  10. vidra

    vidra

    Joined:
    Jun 8, 2014
    Posts:
    7
    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.
     
  11. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    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.
     
  12. vidra

    vidra

    Joined:
    Jun 8, 2014
    Posts:
    7
    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.
     
  13. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Please let us know if you find out any additional details from the crash reports, as mentioned. Previous releases are here https://forum.unity.com/threads/uni...-core-package-2-2-1-are-now-available.415517/
     
  14. RedBandGames

    RedBandGames

    Joined:
    Nov 4, 2016
    Posts:
    1
    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).
    Zrzut ekranu 2020-12-10 o 17.42.17.png
     
  15. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    We are checking. If you can find steps to reproduce, it would be appreciated. But we will inspect the code regardless.
     
  16. Hellfim

    Hellfim

    Joined:
    Sep 11, 2014
    Posts:
    92
    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?
     
  17. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    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://forum.unity.com/threads/sample-iap-project.529555/
     
  18. Hellfim

    Hellfim

    Joined:
    Sep 11, 2014
    Posts:
    92
    Okay, so I sent you my logs in a PM
     
  19. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    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
     
    Last edited: Dec 10, 2020
  20. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Please provide your project, unless you can identify any differences between the Sample IAP project. Please DM me
     
  21. Hellfim

    Hellfim

    Joined:
    Sep 11, 2014
    Posts:
    92
    Well, actually I've managed to reproduce it on the Sample IAP project. You just need to update Unity IAP to the latest version (but I guess v2.2.0 is the broken one), then build and viola - the exception is there. I also added Unity-Logs-Viewer plugin to the project to check logs on the device, but that shouldn't be a problem.

    I guess it somehow might be related to the device operation system or smth. My test cases were:
    Alcatel 4047D with Android 7.0, gsm MT6580M, kernel 3.18.35+, build 010 05
    Xiaomi Mi 6 with Android 9 PKQ1.190118.001 MIUI Global 11.0.6.0 Stable (PCAMIXM), gsm AT20-0307_2204_3754711, kernel 4.4.153-perf+
     
  22. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Sorry, I don't understand your voila comment, might you be able to elaborate? When do you get the error? Are you making a purchase? Is it during initialization? What type of product if purchasing? I am able to purchase a consumable, non-consumable and subscription without the error, with the Sample IAP project using my Samsung Galaxy S7. Please provide your steps to reproduce.
     
    Last edited: Dec 11, 2020
  23. Hellfim

    Hellfim

    Joined:
    Sep 11, 2014
    Posts:
    92
    Sorry, my bad I didn't explain it through.
    You just need to launch a build. The exception appears after initialization is complete. There is no need to press any buttons.
     

    Attached Files:

  24. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    That screenshot doesn't show initialization as completed, it crashes the app prior to that? Please add additional MyDebug statements to see exactly where it is. Also, please show your products as listed on the Google play store and defined in the app. Do they all have a Description? Also, please provide the full adb logcat logs as an attachment. We have a good idea where in the code the issue might be, but we need steps to reproduce so we can confirm and test a potential fix.
     
  25. Hellfim

    Hellfim

    Joined:
    Sep 11, 2014
    Posts:
    92
    Yep, sorry, didn't check init callback, thought Complete=true is the initialization message.
    No, app doesn't crash it loads without any visible problems, though the exception is in the console
    I'm using Sample IAP without any changes, so I guess it should be set up.

    Anyway, I guess I've found the problem (or a clue for you) - exception appears when I make a build with Unity 2019.2.1f1, and it works fine in the 2020.1.2f1. Hope that helps.
     
  26. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Unfortunately it doesn't help. We are not able to reproduce here with the steps you've mentioned. Can you provide the information I requested? And your "guess that it should be set up", you would need to have created the same products on your developer Dashboard, did you do this? Please show a screenshot of your Google dashboard where you have defined the products for the Sample IAP project such as "noads" and "gold50" with the full steps mentioned here https://docs.unity3d.com/Manual/UnityIAPGoogleConfiguration.html In your own Google Developer Dashboard at https://play.google.com/apps/publish , be sure to add a Description for your products, perhaps we have an issue with a missing field. Hmm, I'm not able to blank out the Description field on my dashboard, so apparently it's not that since it's a required field.
     
    Last edited: Dec 11, 2020
  27. Hellfim

    Hellfim

    Joined:
    Sep 11, 2014
    Posts:
    92
    Where do you want me to put additional debug messages? It seems that exception happens somewhere in the internal initialization. If I comment out UnityPurchasing.Initialize(this, builder); then there is no exception, if I leave it as is exception appears right after game launch.
    No, I did not. And services for the project ain't set up either. Although Unity IAP shouldn't throw exceptions, instead it should throw OnInitializeFailed shouldn't it? The exception appears on both signed and unsigned versions by the way.

    I can't setup a different project in the Dashboard right now. I'm sure that my live project is correctly set up there as it works fine with v2.1.1 and breaks with the v2.2.0.

    I'm attaching a Sample IAP project (without any set up, yet it shouldn't throw exceptions) with the problem below
    https://drive.google.com/file/d/1ThpQroZU6MtLVD1OxVykl8hoAyb98Ab-/view?usp=sharing
     
  28. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    We believe you! We are not saying that your project is not correctly set up. Of course it shouldn't throw exceptions, we are trying to fix that, no argument there. There looks like there is indeed an issue. But we need steps to reproduce here so that we can test any potential fix we might want to release. We are looking to see why you can reproduce and we cannot, so we are looking for differences, and why I ask you provide the information requested. Please show a screenshot of your Google Dashboard products so we might compare. The sooner you can provide this information, the sooner we can fix it! Also, what version of Unity are you using? Since it happens without any products configured, it likely ISN'T in your dashboard, but we need to rules things out. I'm using Unity 2020.1.6f1 here.
     
    Last edited: Dec 11, 2020
  29. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    I also see the exception in your APK when I install it. When I build the Sample IAP project here, I don't see it. What version of Unity are you using? Also, what version of IAP? In the Editor, use menu Window/Unity IAP/IAP Updates. Also, what version of the In App Purchasing library in Package Manager?
     
  30. Hellfim

    Hellfim

    Joined:
    Sep 11, 2014
    Posts:
    92
    Well, there are around 100 IAPs in the project I'm working on. Iis an example setup for one of them
    As I mentioned earlier the exception appears when I make a build with 2019.2.1f1, but everything works fine in the 2020.1.2f1
    v2.1.1 works fine in both Unity versions
    v2.2.0 is broken for Unity 2019.2.1f1, but works fine with 2020.1.2f1
    It's 2.0.6 (last available for me)
     

    Attached Files:

  31. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    I'm not able to reproduce when using the most recent IAP 2.2.4 (Asset) and 2.2.1 (PacMan) with Unity 2019.4.1f1. Please test with the latest version. In Package Manager, you can select Show Preview Packages from the Advanced dropdown to see additional versions.
     
  32. Hellfim

    Hellfim

    Joined:
    Sep 11, 2014
    Posts:
    92
    v2.2.4 (asset) also doesn't work.
    v.2.2.1 (package manager) is unavailable for me (my Unity version) see attached screenshot

    Well, I still suggest you try to reproduce this with 2019.2.1f1
     

    Attached Files:

  33. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Are you not able to use Unity 2019.4.1f1? It works with that version at least. If I were to reproduce with 2019.2, the recommendation would be to upgrade to 2019.4. What happens when you click the drop down arrow on the left to see the available versions from your screenshot?

    Versions.png
     
  34. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    I have confirmed that In App Purchasing library 2.2.1 is available in Unity 2019.2.1f1
     
  35. Hellfim

    Hellfim

    Joined:
    Sep 11, 2014
    Posts:
    92
    Yep, 2.2.1 is there, never paid attention to that arrow, sorry. It didn't fix the issue though :(
    Well, right now I'm not able to switch to 2019.4.1f1, yes. I'm planning to update Unity version next year. If the problem is with 2019.2 then I'll just stick to Unity IAP v2.1.1 till you fix the problem/time for project's Unity version update comes.
     
  36. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Are you building on Mac or Windows? I'm installing Android support now for 2019.2.1f1 on Windows.
     
  37. Hellfim

    Hellfim

    Joined:
    Sep 11, 2014
    Posts:
    92
    Windows 10
     
  38. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    That was it, thanks for your patience. It fails as you mentioned with 2019.2.1f1. Something changed between 2019.2.1f1 and 2019.4.6f1.
     
    Last edited: Dec 11, 2020
  39. Hellfim

    Hellfim

    Joined:
    Sep 11, 2014
    Posts:
    92
    Okay, great! Any chances that you are going to solve this isse for 2019.2.1f1?
     
  40. domdev

    domdev

    Joined:
    Feb 2, 2015
    Posts:
    375
    this happening now..using IAP demo scene..
    IAP version 2.2.1
    unity version 2019.2.4.f1
    windows 10
    uploaded also the log file
     

    Attached Files:

  41. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    As mentioned, we are aware. Your log file doesn't contain the error, but thanks. We are working on it.
     
  42. domdev

    domdev

    Joined:
    Feb 2, 2015
    Posts:
    375
    lol wrong log
     

    Attached Files:

    • log.txt
      File size:
      1.6 KB
      Views:
      240
  43. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Please compare to the most recent IAP release, we are expecting 2.2.5 this week, perhaps within the next day or so.
     
  44. domdev

    domdev

    Joined:
    Feb 2, 2015
    Posts:
    375
    okay will try.. but right now we rollback and its working again
     
  45. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Yes, that would be expected also.