16

I am working on learning in-app billing but I am having a problem with the google's in-app billing example, the Dungeon one.

I have already set up the application, added my public key, and changed the API_VERSION to 1 in the makeRequestBundle().

I have already exported and signed the application and uploaded it onto Google Play and saved it as a draft with a few pictures and activated the apk. I also added both the sword_001 and potion_001 as published in-app purchases!

Next I installed the signed app onto my phone but when I try to purchase either the sword or the potion I get an Item unavailable error

The item you requested is not available for purchase.

I even tried on a different device to make sure it wasn't because developer's can't purchase their own products, and I get the same message on both devices.

What have I missed?

4

10 Answers 10

39

Check your versionCode. It can't be higher than the last published/unpublished version in any of your distribution channels (prod/beta/alpha).

5
  • 1
    It work well for me ! thanks, I nearly give up it. It help me . Commented Oct 21, 2015 at 9:19
  • This is very important to keep in mind. I was developing the app and just stumbled into payments and encountered this error. I paniced. Found this reply. Tried payments with the app in production. Found everything going OK.
    – JaydeepW
    Commented Oct 30, 2015 at 9:40
  • I had the app released and with billing working. Testing the next version I found this error. Your answer has made me figure out why! Of course I cannot check billing in the next version until I publish it. So I have published it with an 1% rollout in order to test this and it worked. Thanks! Commented Aug 30, 2019 at 9:14
  • This should be documented by Google. I got crazy finding it out
    – Corbella
    Commented Oct 15, 2020 at 10:34
  • Does it mean that we have to publish a first public version without being able to test it?
    – Thomas
    Commented Jan 7, 2021 at 0:06
25

In app billing seems fraught with pitfalls, but this is what I found that affected availability of items for purchase and also suitability of application:

  1. My code for what it was worth was strongly based on the Google Android demo, but I stripped out a lot of the complexity. I have a feeling that having got it to work a better result would be produced by writing it all again from scratch.
  2. I got the static test product ids going first.
  3. Despite what the documentation says, it seemed to me that the purchase item(s) must be published, even when using a test account. Mine didn't work when they weren't, anyway, and I waited quite a long time to see if they would start to work as others have suggested - they still didn't.
  4. You (I anyway) can't publish a purchase item without publishing the app, so what I did was upload and publish the app, create the purchase items, publish them (big button at the bottom of the page), then unpublish the app again. This seems to leave the items published.
  5. The app must be signed in the usual way (I did this by exporting from Eclipse) before uploading, but what isn't so obvious is that the app you load to the mobile MUST also be signed in the same way - ie a (debug signed) version loaded to the device by Eclipse - run or debug - isn't going to work.
  6. They also both need the same version number, I think. Not 100% sure. If so that would unfortunately kind of imply that customers with old versions installed can't purchase anything without upgrading.
  7. When the app is uploaded to Google, it can take several hours before it becomes available and you get all the right responses for the in-app billing. I find 1-2 hours typically.
  8. I suspect the other comments on this subject about whether you use a gmail or googlemail test account might be red herrings, but for what it is worth, my test account is gmail.
  9. I did come across a useful little note on the internet somewhere about how to change your primary account on the mobile without having to do a hard reset (and consequently losing everything), but unfortunately I haven't managed to find it again.
  10. What I did find though is that one can have several google accounts on the mobile, and then select the one to be used by Google Play.

Hope this helps somebody. I have to say its a pretty complicated system, with not many switten down answers, and I nearly gave up on it.

3
  • In my case purchases worked ok the app is already on production and when I increased version number the in-app purchases stopped working. So this suggestion was valid for me. "They also both need the same version number, I think. Not 100% sure. If so that would unfortunately kind of imply that customers with old versions installed can't purchase anything without upgrading." Commented Oct 15, 2015 at 14:15
  • Sorry for asking here @nmw01223, but do you have any experience on how to handle VAT tax with In-app billing, and which countries it is done automatically by google, and which I have to manually report/pay VAT tax to? see stackoverflow.com/questions/36506835/… Commented Apr 8, 2016 at 18:50
  • Absolutely none, I am afraid.
    – nmw01223
    Commented Apr 10, 2016 at 8:19
15

If your app are on closed alpha testing, you have to sign in with your test account to Opt-in URL; https://play.google.com/apps/testing/{your.app.namespace}

2
  • This worked for me. The URL I get from Manage Testers Opt-in url link is different. Something like this play.google.com/apps/internaltest/<random digits>. I thought this was right since its from the google console itself. I checked everything mentioned above and nothing was wrong except for the opt in link. It's very easy to miss since it is not that technical.thank you for your answer.
    – rose000
    Commented Oct 20, 2018 at 2:54
  • 1+ This worked like magic, 2 days of debugging, and nothing worked.
    – ibrhm117
    Commented Aug 3, 2022 at 7:24
7

My experience on this error is:

  1. Make sure to upload the signed APK to developer console.

  2. Make sure to install the signed APK on your device not launch the app in the debugger.

  3. Make sure to create a test account in your developer console.

  4. Make sure to sign in your device with your test account.

  5. Make sure to create in app billing in your developer console and finally activate the item from the console!!! (this is the one that got me after fully following google's tutorial)

0
2

It's no longer sufficient to just upload an unpublished draft apk to test in-app billing. What you need to do is upload an apk to the alpha or beta apk section on the Developer Console. Then, you need to publish it. If you also have a draft apk in the Production APK section, be sure to delete it before you publish. Otherwise it will be available to everyone.

Publishing an alpha or beta apk makes that apk available to only those testers that you specify/allow.

Here is Google's documentation on this:

https://support.google.com/googleplay/android-developer/answer/6062777?rd=1

1

Well I found a solution to my problem. I wasn't able to get Google's in app purchasing example to work but I was able to get this InApp Billing Tutorial to work using the steps I mentioned in my original post.

If nothing else this may be helpful to someone to see all of the steps that need to be done to test one of the in-app billing examples.

1
  • Sorry for asking here @Gatekeeper, but do you have any experience on how to handle VAT tax with In-app billing, and which countries it is done automatically by google, and which I have to manually report/pay VAT tax to? see stackoverflow.com/questions/36506835/… Commented Apr 8, 2016 at 18:44
1

Also had this problem for a couple of days and searched around a lot. I found this guy who said deleting the app and then reuploading fixed his problem, and that actually worked for me aswell.

Try that, delete your app from the developer console entirely. And reuppload a new signed apk and set it up all over again

1

Publishing the app did the trick for me(and leaving it published (!)). I had to wait a bit for Google to update their database as well, as mentioned elsewhere, changes on Google Play are not immediate.

1

Anecdotal Supplement: If you have an existing app in the portal already and you want to test a signed version, but not upload it into the portal for distribution. Do the normal steps to build a signed version BUT use your latest version code that is uploaded into the portal. You will will be able to do a quick and dirty test of purchasing (you can't upload this version on the Google Play portal, but it's a means to an end for a localized test (or even as a way to allow side loaded distributed versions/flavors that use Google Play for billing legitimately.)

3:)

1
  • Thank you, that was helpful
    – MaxF
    Commented Mar 5, 2018 at 11:00
0

Check if your device have more than one account then remove other accounts and keep the account you have entered in play console then it will be solved.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.