Search Unity

[Solved] Unity IAP Null Reference Exception showing up in Unity Analytics. Android Build (4.1.2)

Discussion in 'Unity IAP' started by Michieal, Jun 10, 2017.

Thread Status:
Not open for further replies.
  1. Michieal

    Michieal

    Joined:
    Jul 7, 2013
    Posts:
    92
    Hi,
    First off, I apologize if this is a duplicate issue / thread. I'm using Unity 5.6.1f and the updated Unity IAP.
    I'm finding this in Unity Analytics... and I have no idea where to start to Fix it.
    From Unity Analytics / App Performance:
    Message
    NullReferenceException: Object reference not set to an instance of an object
    Stack trace
    UnityIAP.ProcessPurchase (UnityEngine.Purchasing.PurchaseEventArgs e)
    UnityEngine.Purchasing.StoreListenerProxy.ProcessPurchase (UnityEngine.Purchasing.PurchaseEventArgs e)
    UnityEngine.Purchasing.PurchasingManager.ProcessPurchaseIfNew (UnityEngine.Purchasing.Product product)
    UnityEngine.Purchasing.PurchasingManager.OnProductsRetrieved (System.Collections.Generic.List`1 products)
    UnityEngine.Purchasing.NativeJSONStore.OnProductsRetrieved (System.String json)
    UnityEngine.Purchasing.ScriptingUnityCallback+<OnProductsRetrieved>c__AnonStorey1.<>m__0 ()
    UnityEngine.Purchasing.Extension.UnityUtil.Update ()

    Please Note: this is with the IAPDemo.cs script, and I have added in the products to both the script and using the catalog manager. I made Purchase buttons, dropped them onto the main canvas in a panel that gets gameObject.SetActive(true); when the store is needed.
    The test purchases work 95% of the time; on the rare occasion, it will fail and close my application on my test device. In that instance, the purchase *never* shows up.
    The only platform targeted with the build is Android, and Google Play Store. Everything else is commented out.

    Thank you for all help with this - I'm trying to get it down (first time using Unity's IAP)
     
  2. Benvictus

    Benvictus

    Joined:
    Sep 12, 2013
    Posts:
    87
    @MichiealO

    I'm sorry to hear that you are seeing errors in your project.

    If you are using the "Codeless IAP" then you will not need to use the IAPDemo.cs script. I would ask that you remove the IAPDemo.cs script from your scene.

    In regards to the NullReferenceException:
    Can you please double-click the error in the console, this will take you to the line in your code where this happens. Can you share this with me?

     
  3. Michieal

    Michieal

    Joined:
    Jul 7, 2013
    Posts:
    92
    @BenStoneman Sorry that I didn't see this sooner!!!

    I only find this error in the analytics section on the WEB PAGE... I don't ever see it in the Editor. Hence having no clue where to start with it. I deleted the demo script and removed my modified version of the script. It's good to know that you don't have to do both.

    And I just went into check, and I am getting told that I do not have access to Unity Analytics, that I need to see the store for purchasing options. I have the pro version (Internal Developer)... But, Even though my app uses the analytics service, and it says that it's free... So, I'm totally confused here. Did something change and I just didn't know that it changed?
     
  4. Michieal

    Michieal

    Joined:
    Jul 7, 2013
    Posts:
    92
    Also, is there a way to display a receipt using the Codeless IAP? I want my customers to be able to reference transactions, and I want a way to be able to store their transactions so I can reference them.
     
  5. ap-unity

    ap-unity

    Unity Technologies

    Joined:
    Aug 3, 2016
    Posts:
    1,519
    @MichiealO,

    The receipt is available in the Product that is send to the On Purchase Complete callback. So you can handle the receipt any way you'd like. In order to display it, you would have to parse it and the format depends on the platform and store:
    https://docs.unity3d.com/Manual/UnityIAPPurchaseReceipts.html


     
    Michieal likes this.
Thread Status:
Not open for further replies.