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

IAP error on device, but works in editor.

Discussion in 'Unity IAP' started by galloper, Aug 22, 2019.

  1. galloper

    galloper

    Joined:
    Aug 5, 2017
    Posts:
    31
    Hello, sorry for creating a thread on this, but I'm kinda stuck.
    I'm trying to add the proverbial "remove ads" IAP into my game.
    First I did it with regular scripting, then got frustrated and remade it with codeless IAP. Anyway, it all works in the editor, not much so on actual devices.
    Logcat shows these errors when the button "buy no ads" is pressed on the device:

    08-22 11:36:02.697: I/Unity(28812): IAPButton.PurchaseProduct() with product ID: removeads
    08-22 11:36:02.697: I/Unity(28812): UnityEngine.Purchasing.IAPButton:purchaseProduct()
    08-22 11:36:02.697: I/Unity(28812): UnityEngine.Events.UnityAction:Invoke()
    08-22 11:36:02.697: I/Unity(28812): UnityEngine.Events.UnityEvent:Invoke()
    08-22 11:36:02.697: I/Unity(28812): UnityEngine.EventSystems.EventFunction`1:Invoke(T1, BaseEventData)
    08-22 11:36:02.697: I/Unity(28812): UnityEngine.EventSystems.ExecuteEvents:Execute(GameObject, BaseEventData, EventFunction`1)
    08-22 11:36:02.697: I/Unity(28812): UnityEngine.EventSystems.StandaloneInputModule:processTouchPress(PointerEventData, Boolean, Boolean)
    08-22 11:36:02.697: I/Unity(28812): UnityEngine.EventSystems.StandaloneInputModule:processTouchEvents()
    08-22 11:36:02.697: I/Unity(28812): UnityEngine.EventSystems.StandaloneInputModule:process()
    08-22 11:36:02.697: I/Unity(28812):
    08-22 11:36:02.697: I/Unity(28812): (Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 48)
    08-22 11:36:02.715: E/Unity(28812): Exception: Error: called non-existent method System.Boolean UnityEngine.VR.VRSettings::get_enabled()
    08-22 11:36:02.715: E/Unity(28812): at UnityEngine.VR.VRSettings.get_enabled () [0x00000] in <00000000000000000000000000000000>:0
    08-22 11:36:02.715: E/Unity(28812): at UnityEngine.Purchasing.GooglePlayAndroidJavaStore.Purchase (System.String productJSON, System.String developerPayload) [0x00000] in <00000000000000000000000000000000>:0
    08-22 11:36:02.715: E/Unity(28812): at UnityEngine.Purchasing.JSONStore.Purchase (UnityEngine.Purchasing.ProductDefinition product, System.String developerPayload) [0x00000] in <00000000000000000000000000000000>:0
    08-22 11:36:02.715: E/Unity(28812): at UnityEngine.Purchasing.PurchasingManager.InitiatePurchase (UnityEngine.Purchasing.Product product, System.String developerPayload) [0x00000] in <00000000000000000000000000000000>:0
    08-22 11:36:02.715: E/Unity(28812): at UnityEngine.Purchasing.CodelessIAPStoreListener.InitiatePurchase (System.String productID) [0x00000] in <00000000000000000000000000000000>:0
    08-22 11:36:02.715: E/Unity(28812): at UnityEngine.Events.UnityAction.Invoke () [0x00000] in <00000000000000000000000000000000>:0
    08-22 11:36:02.715: E/Unity(28812): at UnityEngine.Events.UnityEvent.Inv

    I confess I use 2019.3.0a7 which is alpha and IAP installed version is 1.22. I think I saw you previously say somewhere here on this forum that even stable versions have the "spaces in path" problem solved, so if not that, what is the cause of my problem?
     
  2. SamOYUnity3D

    SamOYUnity3D

    Unity Technologies

    Joined:
    May 12, 2019
    Posts:
    626
    From your log I see you got UnityEngine.VR.VRSettings.get_enabled () error.

    The VR settings error is a known issue if you do not accept the "Update API, have you made a backup?" prompt during the IAP import. If you do not get this popup, then you likely have a compiler error which would prevent the upgrade from finishing correctly. Make sure you have no other files that reference IAP outside of the Plugins folder. This post may help also: https://forum.unity.com/threads/iap-troubleshooting-remove-and-reinstall-unity-iap.511747/
     
  3. galloper

    galloper

    Joined:
    Aug 5, 2017
    Posts:
    31
    I see, thank you for your answer. Even though I'm pretty sure I never declined that prompt, can it be just an issue with 2019 Unity?
    Today I restored my project from backup where IAP was not yet added, started with importing IAP from asset store, but it didn't work as expected, then I enabled it from "Services" and IAP did work, again, only in the editor.
     
  4. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Yes, there are issues with IAP on Unity 2019. If you don't get that Update API prompt, then the VR error is expected. Also, before you update or install IAP, there can be no compile errors in your project. That is, if you remove IAP before upgrading, you must make sure there are no compile errors after you remove IAP, and it runs in the Editor, before installing again.