Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[Solved] NullReferenceException when moving UnityPurchasing folder outside Plugins

Discussion in 'Unity IAP' started by fadhilnoerafif, Dec 13, 2016.

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

    fadhilnoerafif

    Joined:
    Nov 8, 2016
    Posts:
    5
    Hi,

    I am trying to move the UnityPurchasing folder outside of Plugins. However when I tried to move them, the editor shows NullReferenceException, and the Android Targeting menu cannot be chosen.

    Code (CSharp):
    1. NullReferenceException: Object reference not set to an instance of an object
    2. UnityEngine.Purchasing.UnityPurchasingEditor.ConfigureProject (AndroidStore target)
    3. UnityEngine.Purchasing.UnityPurchasingEditor.TargetAndroidStore (AndroidStore target)
    4. UnityEngine.Purchasing.UnityPurchasingEditor.<UnityPurchasingEditor>m__0 ()
    5. UnityEditor.EditorApplication.Internal_CallDelayFunctions () (at /Users/builduser/buildslave/unity/build/artifacts/generated/common/editor/EditorApplicationBindings.gen.cs:232)
    6.  
    Is there any way to solve this? I can normally move the folder with most of other plugins (as long we retain the folder structure beneath) but I can't seem to do this for Unity IAP.

    Thanks!
     
  2. fadhilnoerafif

    fadhilnoerafif

    Joined:
    Nov 8, 2016
    Posts:
    5
    Update : I just tested the build while moving the plugins to folder called UnityIAP.
    The folder structure is

    > UnityIAP
    > Plugins
    > UnityPurchasing
    > etc​

    The NullReferenceException error above is still thrown, however when I tried to purchase item (in Android), it works normally.
    So probably there is something to do with the Editor scripts.
     
  3. ap-unity

    ap-unity

    Unity Technologies

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

    Yeah, reorganization of the folder is currently not supported. That is something we hope to support in the future to bulletproof IAP.
     
  4. raphaelbaldi

    raphaelbaldi

    Joined:
    Mar 4, 2008
    Posts:
    23
    We're using the default structure and getting the same error as well:
    Code (CSharp):
    1. NullReferenceException: Object reference not set to an instance of an object
    2. UnityEngine.Purchasing.UnityPurchasingEditor.ConfigureProject (AndroidStore target)
    3. UnityEngine.Purchasing.UnityPurchasingEditor.TargetAndroidStore (AndroidStore target)
    4. UnityEngine.Purchasing.UnityPurchasingEditor.TargetGooglePlay ()
    Using Unity 5.6.0p3 and IAP 1.10.1

    Our project is quite big and we weren't able to get a repro in a smaller one just yet.
     
  5. ap-unity

    ap-unity

    Unity Technologies

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

    Just to clarify what was mentioned above, the directory structure and all of the files must be in the default location. Any changes will result in errors as you describe.

    If you have not modified anything in the Purchasing folder, then would you be able to provide us a copy of the project that is experiencing this issue. You can PM me or send a support ticket:
    https://analytics.cloud.unity3d.com/support/

    Would you be able to provide some repro steps? What behavior triggers this exception specifically?
     
  6. raphaelbaldi

    raphaelbaldi

    Joined:
    Mar 4, 2008
    Posts:
    23
    Sorry for not replying earlier. We're using Unity IAP as is now (no modifications/reorganizations). The project compiles just fine as long as we don't use batch mode. When using batchmode both the Analytics and UnityPurchasing libraries are not linked and the project fails to compile. The same happens when trying to deploy the project using Unity Cloud build (also, it has been failing lately due to timeouts during LFS checkout). We're now using Unity 5.6.1f1. I'll try to send you guys a repro case in a smaller project as we believe the only issue is using IAP/Analytics in any of your scripts and trying to deploy the project running a custom method (-executeMethod) in batch mode.
     
  7. ap-unity

    ap-unity

    Unity Technologies

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

    A repro project would be very helpful.

    One of my colleagues also suggested trying to run the build from the command line, but don't add the -batchmode flag. The process will run without hiding the UI interactions, so you might be able to get a sense of what the issue is.
     
Thread Status:
Not open for further replies.