Search code examples
unity-game-enginein-app-purchasein-app-billing

Unity's IAP - initialization failure after migration to Google Billing version 3


Yesterday I was pushing a new release of my game to Google Play Store via Developer Console. After successful bundle transfer I've received a warning message that I'm using an older version of an in app billing module and it is advisable to migrate to current one (v3). Therefore I've updated all the packages/IAP Unity services to the newest versions (Unity ver: 2019.4.18f1 (64-bit), IAP package: In App Purchasing 2.2.2, Unity Services IN-APP PURCHASING "up to date").

The problem I'm encountering now occur during the initialization process which works in an unpredictable way. Once every now and again it work correctly resulting in a proper inap behavior - initialization as well as product's purchase works perfectly well. Unfortunately more than often the initialization process fails with the following message taken from logcat:

I/Unity: UnityIAP Version: 2.2.6
W/Unity: Unavailable product test-test
(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)
// etc...

Solution

  • In my project Unity's billing module was wrapped in a singleton class which upon its first usage was performing initialization of Unity's IAP (usage of a singleton with possible initialization: IAPManager.Instance).

    In order to initialize the module I was using the following piece of code - IAPManager.Instance.Init() which in result was triggering Init() first inside IAPManager.Instance and second time at IAPManager.Instance.Init(). Because of that, there was two folded execution of Unity's IAP initialization which unfortunately failed with Products unavailable logcat message.

    Triggering Unity's IAP initialization one time only fixed the issue.