Search Unity

IAP not working. Debug window not showing up due to NullReferenceException

Discussion in 'Unity IAP' started by banyiknandor1, Mar 12, 2021.

  1. banyiknandor1

    banyiknandor1

    Joined:
    Apr 28, 2018
    Posts:
    2
    I've been checking several forums threads, watched tutorials but this problem seems quite unusual.
    Here is the error log, any idea what causes it?

    NullReferenceException: Object reference not set to an instance of an object
    UnityEngine.Purchasing.UIFakeStore.InstantiateDialog () (at Library/PackageCache/com.unity.purchasing@3.0.1/Runtime/Stores/FakeStore/UIFakeStore.cs:175)
    UnityEngine.Purchasing.UIFakeStore.StartUI (System.String queryText, System.String okayButtonText, System.String cancelButtonText, System.Collections.Generic.List`1[T] options, System.Action`2[T1,T2] callback) (at Library/PackageCache/com.unity.purchasing@3.0.1/Runtime/Stores/FakeStore/UIFakeStore.cs:153)
    UnityEngine.Purchasing.UIFakeStore.StartUI[T] (System.Object model, UnityEngine.Purchasing.FakeStore+DialogType dialogType, System.Action`2[T1,T2] callback) (at Library/PackageCache/com.unity.purchasing@3.0.1/Runtime/Stores/FakeStore/UIFakeStore.cs:128)
    UnityEngine.Purchasing.FakeStore.FakePurchase (UnityEngine.Purchasing.ProductDefinition product, System.String developerPayload) (at Library/PackageCache/com.unity.purchasing@3.0.1/Runtime/Stores/FakeStore/FakeStore.cs:163)
    UnityEngine.Purchasing.FakeStore.Purchase (System.String productJSON, System.String developerPayload) (at Library/PackageCache/com.unity.purchasing@3.0.1/Runtime/Stores/FakeStore/FakeStore.cs:132)
    UnityEngine.Purchasing.JSONStore.Purchase (UnityEngine.Purchasing.ProductDefinition product, System.String developerPayload) (at Library/PackageCache/com.unity.purchasing@3.0.1/Runtime/Stores/BaseStore/JSONStore.cs:354)
    UnityEngine.Purchasing.PurchasingManager.InitiatePurchase (UnityEngine.Purchasing.Product product, System.String developerPayload) (at Library/PackageCache/com.unity.purchasing@3.0.1/Runtime/Purchasing/PurchasingManager.cs:60)
    UnityEngine.Purchasing.PurchasingManager.InitiatePurchase (System.String purchasableId, System.String developerPayload) (at Library/PackageCache/com.unity.purchasing@3.0.1/Runtime/Purchasing/PurchasingManager.cs:69)
    UnityEngine.Purchasing.PurchasingManager.InitiatePurchase (System.String productId) (at Library/PackageCache/com.unity.purchasing@3.0.1/Runtime/Purchasing/PurchasingManager.cs:43)
    UnityEngine.Purchasing.CodelessIAPStoreListener.InitiatePurchase (System.String productID) (at Library/PackageCache/com.unity.purchasing@3.0.1/Runtime/Codeless/CodelessIAPStoreListener.cs:145)
    UnityEngine.Purchasing.IAPButton.PurchaseProduct () (at Library/PackageCache/com.unity.purchasing@3.0.1/Runtime/Codeless/IAPButton.cs:108)
    UnityEngine.Events.InvokableCall.Invoke () (at <a9810827dce3444a8e5c4e9f3f5e0828>:0)
    UnityEngine.Events.UnityEvent.Invoke () (at <a9810827dce3444a8e5c4e9f3f5e0828>:0)
    UnityEngine.UI.Button.Press () (at C:/Program Files/Games/2020.1.5f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/UI/Core/Button.cs:68)
    UnityEngine.UI.Button.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData) (at C:/Program Files/Games/2020.1.5f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/UI/Core/Button.cs:110)
    UnityEngine.EventSystems.ExecuteEvents.Execute (UnityEngine.EventSystems.IPointerClickHandler handler, UnityEngine.EventSystems.BaseEventData eventData) (at C:/Program Files/Games/2020.1.5f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/ExecuteEvents.cs:50)
    UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1] functor) (at C:/Program Files/Games/2020.1.5f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/ExecuteEvents.cs:261)
    UnityEngine.EventSystems.EventSystem:Update() (at C:/Program Files/Games/2020.1.5f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/EventSystem.cs:376)
     
  2. francisIsFine

    francisIsFine

    Joined:
    Jun 26, 2018
    Posts:
    40
    If you haven't already, Go to Services > In App Purchasing and scroll down to Welcome section where you'll find a button to import further IAP files for each store. It would say "Reimport" if you've already done this (Screenshot below).

    Screen Shot 2021-03-15 at 5.49.54 PM.png

    This will import files under Assets > Plugins > UnityPurchasing. If you were following the note written in package manager about upgrading to 3.0.1 and avoiding compile errors, then you might have removed the entire UnityPurchasing folder in this directory as the intsructions aren't exaclty clear on which folders need removed. I think you can delete the rest but leave Assets > Plugins > UnityPurchasing > Resources and its contents to avoid that error you're having. That's because UIFakeStore.cs is trying to find the prefab living in that folder.

    Screen Shot 2021-03-15 at 5.48.54 PM.png
     
    tommijuu and kmedved like this.
  3. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    I am also seeing inconsistent behavior when I delete the /Library folder, we are checking further.
     
  4. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    In my case, I was able to resolve the issue by deleting the /Library folder. I noticed the following at the top of the tangle files

    #if UNITY_ANDROID || UNITY_IPHONE || UNITY_STANDALONE_OSX || UNITY_TVOS

    but I'm on Windows. Deleting the #if statement worked for me.
     
  5. litebox

    litebox

    Joined:
    Aug 29, 2011
    Posts:
    158
    I also did migration from IAP 2.1.0 to 3.0.2 and noticed this problem: plugin instruction says we need to delete Plugins/UnityPurchasing folder, because whole plugin is moved to the Packages. However, this package doesn't have Resources/UIFakeStoreCanvas.prefab.

    To get this prefab we have to options:
    1. Save it before deleting folder from Plugins
    2. Import Sample IAP project from PackageManager - this will create Samples folder with Resources/UIFakeStoreCanvas.prefab
     
    danle2584 and John_Corbett like this.
  6. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Yes, this is an issue we are working on.
     
  7. BigCommunityApps

    BigCommunityApps

    Joined:
    Mar 6, 2021
    Posts:
    2
    do you know approx when it will be fixed?
     
    OWL7seven likes this.
  8. chethanb

    chethanb

    Joined:
    Jan 2, 2017
    Posts:
    1
    The above workaround worked for me.
    If you have deleted the Assets > Plugins > UnityPurchasing as in the instruction and installed from Package manager then go to the IAP window and reimport only by ticking Assets > Plugins > UnityPurchasing > Resources leaving rest unticked. Saves you some time.

     
  9. BigCommunityApps

    BigCommunityApps

    Joined:
    Mar 6, 2021
    Posts:
    2
    Fixed this issue by just importing samples under unity IAP from package manager! anyway this miust have been fixed!
    my unity version 2021.1.6
     
    nek0pi likes this.
  10. nek0pi

    nek0pi

    Joined:
    Mar 16, 2020
    Posts:
    4
    upload_2021-9-16_17-26-27.png

    The current version is 2021.1.7 and plugin version 3.0.2 still needs samples to be downloaded in order to fix this error.
     
    JeffDUnity3D likes this.
  11. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Good point! This should be fixed in IAP 4.0.3 that is currently available
     
    nek0pi likes this.