# IAP and Android

**URL:** <https://forum.defold.com/t/iap-and-android/418>\
**Category:** Questions\
**Created:** [November 3, 2015, 4:18pm UTC](https://forum.defold.com/t/iap-and-android/418 "2015-11-03T16:18:15Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![Johan](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/johan/32/127_2.png) [@Johan](https://forum.defold.com/u/Johan)\
**Post date:** [November 3, 2015, 4:18pm UTC](https://forum.defold.com/t/iap-and-android/418/1 "2015-11-03T16:18:15Z")

</div>

I am trying to implement IAP and have started with Android, but can’t get it to work. The app is published as Alpha and I have added a product, but when I do iap.list with my product id I get an empty table as product and nil in error. Any pointers?

---

<div class="post-metadata">

**Author:** ![sicher](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/sicher/32/8_2.png) [@sicher](https://forum.defold.com/u/sicher)\
**Post date:** [November 4, 2015, 8:29am UTC](https://forum.defold.com/t/iap-and-android/418/2 "2015-11-04T08:29:00Z")

</div>

It can take some time for the Google servers  
to propagate the info. Check again now and see if the problem persists.

---

<div class="post-metadata">

**Author:** ![Johan](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/johan/32/127_2.png) [@Johan](https://forum.defold.com/u/Johan)\
**Post date:** [November 4, 2015, 10:36am UTC](https://forum.defold.com/t/iap-and-android/418/3 "2015-11-04T10:36:03Z")

</div>

Yes you were right, now it works - but I get an error from Google Play: “Authentication needed. You must log in to your Google account”. I am logged in and I don’t get that prompt when opening in-app purchases in any other app.

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [November 4, 2015, 10:55am UTC](https://forum.defold.com/t/iap-and-android/418/4 "2015-11-04T10:55:14Z")

</div>

Are you using Closed or Open Alpha testing? Is your Google account added to the list of testers? Have you accessed the opt-in link with your Google account and joined the alpha test?

Another thing worth noting is that the version you are installing on your phone must match the version you have uploaded to Google in three ways:

1. It must have the same versionCode
2. It must have the same package name
3. It must be signed using the same certificate and key

---

<div class="post-metadata">

**Author:** ![Johan](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/johan/32/127_2.png) [@Johan](https://forum.defold.com/u/Johan)\
**Post date:** [November 4, 2015, 11:10am UTC](https://forum.defold.com/t/iap-and-android/418/5 "2015-11-04T11:10:47Z")

</div>

I am using Closed Alpha and my account is added and I joined (allthough I did not use the gmail-address that google has generated so that might be it. I have added it now but I guess it will take some time to propagate as well).  
I have not changed versionCode, package name or signing cert and key since uploading.

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [November 4, 2015, 11:47am UTC](https://forum.defold.com/t/iap-and-android/418/6 "2015-11-04T11:47:00Z")

</div>

What do you mean when you say “I did not use the gmail-address that google has generated”?

---

<div class="post-metadata">

**Author:** ![Johan](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/johan/32/127_2.png) [@Johan](https://forum.defold.com/u/Johan)\
**Post date:** [November 4, 2015, 12:08pm UTC](https://forum.defold.com/t/iap-and-android/418/7 "2015-11-04T12:08:51Z")

</div>

My google account is tied to a non-gmail address, but google has decided they want me to have a gmail-address so they have generated one for me that is shown whenever I am logged in (but I can log in with my normal address).

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [November 4, 2015, 12:42pm UTC](https://forum.defold.com/t/iap-and-android/418/8 "2015-11-04T12:42:20Z")

</div>

Ah, ok. I wonder if that’s what causing you’re problem. OTOH I’m using my @king.com address and that’s working fine.

---

<div class="post-metadata">

**Author:** ![Johan](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/johan/32/127_2.png) [@Johan](https://forum.defold.com/u/Johan)\
**Post date:** [November 4, 2015, 2:02pm UTC](https://forum.defold.com/t/iap-and-android/418/9 "2015-11-04T14:02:52Z")

</div>

I have changed to the gmail-address and so far it doesn’t help, but I’ll wait until tomorrow

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [November 5, 2015, 5:21am UTC](https://forum.defold.com/t/iap-and-android/418/10 "2015-11-05T05:21:53Z")

</div>

Hmm, I think it’s something else. When I’ve made changes to the alpha/beta test groups the change has had almost instant effect.

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [November 5, 2015, 5:22am UTC](https://forum.defold.com/t/iap-and-android/418/11 "2015-11-05T05:22:29Z")

</div>

Maybe you could invite me to your alpha test? [bjorn.ritzl@gmail.com](mailto:bjorn.ritzl@gmail.com) or [bjorn.ritzl@king.com](mailto:bjorn.ritzl@king.com)

---

<div class="post-metadata">

**Author:** ![Johan](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/johan/32/127_2.png) [@Johan](https://forum.defold.com/u/Johan)\
**Post date:** [November 5, 2015, 6:10pm UTC](https://forum.defold.com/t/iap-and-android/418/12 "2015-11-05T18:10:01Z")

</div>

Now I’m getting “The publisher can not buy this item”, so I’m guessing it’s working. I will try with another google account to confirm.

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [November 5, 2015, 6:53pm UTC](https://forum.defold.com/t/iap-and-android/418/13 "2015-11-05T18:53:30Z")

</div>

> [@Johan](#):
>
> The publisher can not buy this item

I don’t think I’ve ever since this error message. Let me know what it took to fix it.

---

<div class="post-metadata">

**Author:** ![Johan](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/johan/32/127_2.png) [@Johan](https://forum.defold.com/u/Johan)\
**Post date:** [November 5, 2015, 7:11pm UTC](https://forum.defold.com/t/iap-and-android/418/14 "2015-11-05T19:11:18Z")

</div>

Ok, I spoke a little prematurely it seems. The error message mentioned earlier (which is actually my english iterpretation of “Utgivaren kan inte köpa det här objektet”) is what I get when running from a bundled apk with release mode.

If I run the application from Defold with my phone as target, I still get the “Authentication needed” error, and iap.list returns an empty list. I can see that the bundled apk gets the list ok because it displays the price correctly.

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [November 5, 2015, 7:30pm UTC](https://forum.defold.com/t/iap-and-android/418/15 "2015-11-05T19:30:51Z")

</div>

> [@Johan](#):
>
> If I run the application from Defold with my phone as target, I still get the “Authentication needed” error, and iap.list returns an empty list. I can see that the bundled apk gets the list ok because it displays the price correctly.

Hold on. So you’re running from Defold to dmengine.apk, downloaded from [d.defold.com](http://d.defold.com)? That won’t work, unless you’ve changed package name, version code and resigned the APK so that it matches the one you’ve uploaded to Google Play.

Could you also temporarily switch to english so that you can get the “Utgivaren kan inte köpa det här objektet” in English so that It’s easier to search for a solution on StackOverflow etc.

---

<div class="post-metadata">

**Author:** ![Johan](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/johan/32/127_2.png) [@Johan](https://forum.defold.com/u/Johan)\
**Post date:** [November 5, 2015, 7:58pm UTC](https://forum.defold.com/t/iap-and-android/418/16 "2015-11-05T19:58:28Z")

</div>

Ah of course, I was to tired to catch that… It would be great for debugging purposes to be able to resign dmengine - but I guess your not to keen on open sourcing it… 😄

My translation was very close, but not exactly right: “The publisher cannot purchase this item” is the correct error message

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [November 6, 2015, 6:22am UTC](https://forum.defold.com/t/iap-and-android/418/17 "2015-11-06T06:22:34Z")

</div>

Ah, I see. This should explain the casue of your problem and how to fix it: [http://stackoverflow.com/questions/14139034/testing-in-app-billing-the-publisher-cannot-purchase-this-item](http://stackoverflow.com/questions/14139034/testing-in-app-billing-the-publisher-cannot-purchase-this-item)
