[Solved] UnityIAP not initializing properly on Android (PurchasingUnavailable)

Hello everyone,

I am trying really hard to get UnityIAP working for Android (Google Play) but it doesn’t seem to work.
For configuration and scripting, I followed the exact steps showed in those two tutorials : 1 , 2.
My purchasing code looks a lot like the Purchaser script from the first tutorial mentioned above. I just removed the unneeded parts (I only target Android for now and I just want to sell non-consumable content), changed the products ids to match those I entered in Google Play developer console, and added my unlock code (which is why I don’t publish the code here).

Everything works well in the editor, I get all the correct logs :

The Unlock function gets called and the content is unlocked correctly.
But as soon as I try to test it on a real android device, it doesn’t work anymore.
Here are the steps I follow to test it (maybe I am doing something wrong here) :

1 - Build a signed apk.
2 - Upload it on Google Play dev console (Alpha test).
3 - Wait several hours for the updated app to be processed.
4 - Download the app with an android device (I tried several different devices) using a different account than mine (this account has been registered as an alpha tester).
5 - Launch the app and Push my buy button.

When I push that button nothing happens. When I look at the adb logs, I get two errors :

First :

Second :

The second is obviously a consequence of the first.

The documentation says :

I don’t know what to do from now. I tried to look for a way to enable IAP in the android parameters, I disabled the authentication requirement which didn’t change anything, I added a valid credit card, but no luck…

So now I’m really stuck and I would really appreciate all the help you can give me !

P.S : I’m using Unity 5.3.1f1, and UnityIAP 1.7 (also tried the brand new 1.8 with no luck)

Hi @Kroute ,

Can you verify that the target store selected is Google Play? You can do this by going to Window > Unity IAP > Android > Target Google Play. I don’t see this in the docs, which is our bad, I’m sorry about that! I’ll make sure to get it added regardless of whether it fixes this issue :slight_smile:

If that doesn’t work, we really need to be able to see at the very least the full debug log from the device where its not working, from app launch to attempted purchase. The purchasing code and screenshots of the google play developer console are also helpful. I totally understand if you don’t feel comfortable posting these on the forums, so if you’d like you can fill out a support ticket so we can look into it for you!

HI @erika_d ,

Thanks a lot for your answer. I already checked the option Target Google Play in Unity Editor, so I don’t think this is the issue.
But that’s actually not the same problem anymore : since my last post I got UnityIAP working on a test device by doing… almost nothing ! I am not really sure what did the trick so I can’t unfortunately tell precisely what the issue was…

Here’s what I did : I just deleted the app on the devices and reinstalled it from the Play store… and it worked !

My guess is that last time I tried (just before posting), I didn’t wait enough time for my updated app to be processed by Google servers. In that last push I had added the new 1.8 version of UnityIAP. I noticed that this version automatically added a new permission :

So I guess that’s what did the trick but I’m not really sure about that.

So for now it works on all the devices I tested… but one. That device is an old smart-phone which runs on Android 4.1.2. I’ll try to investigate further and to post updates.

2 Likes