*HELP* -- trying to add IAP/IAB on my android game

Hi there, i actually trying to add an iap into my game…but i got some error on it…this is what i did.

I used the sample code given in the IAP tutorial, and put it in a gui script…i tried to test it on the editor if it works but i got an error says: “attempt to index iap(a nil value)” in the debug…this is not actually the first time i encountered this kind of error…but im confused…where did i got this error? On the code itself?..or maybe it is not advisable to try it on the editor? Or maybe the main problem is in my product from googleplay?..any help is very appreciated…thanks!..i know this is a simple problem for you…but please bear me… :’)

Are you running this directly from the editor? There is no IAP support on the desktop platforms. :slight_smile: You need to run this on a device! :thumbsup:

2 Likes

thanks sir for the info that this will not advisable to try directly on the desktop…but do i need to bundle it and upload to the googleplay as an alpha version apk before i will try to test it? Or i can actually test it by running the game on a device via wifi?..thanks…actually.if possible…i only want to try it first on the editor to see if it will generate aome errors before uploasing it on google play even for alpha testing… :’)

You can install apks directly onto your device, just turn on 3rd party sources.

Read this doc: http://www.defold.com/manuals/android/

You can also debug/install directly from your editor.

http://d.defold.com/stable/

Download the apk (not the _release version) and put it on your device - you can go to the above url and download the apk directly from your device’s browser if you have 3rd party sources enabled (google how to for your device).

Open this apk “dmengine”

As long as your home network is setup and your devices can communicate (firewalls can block communication) you can then set up your Android device as the target to build to

If you install this app AirDroid you can upload apks from your web browser directly to your device too (plus a bunch of other handy features)

1 Like

thanks for all the handy stuff that you shared to me…i’ll try it later… :’)

1 Like

Hold on. If you want to try In app purchases on Android there are a number of things you need to do:

  1. Create your app on Google Play. Fill out the Store Listing, Content Rating, Pricing & Distribution and most importantly In-app Products section.
  2. Upload a version of your app, signed with your release certificate as a Beta or Alpha test.
  3. Invite testers (in the APK section on Google Play)
  4. Each tester must click on the Opt-in URL to join the beta/alpha test (available in the APK section on Google Play, just below the list of invited testers)
  5. Publish your Beta/Alpha (no worries, it will only be visible and accessible by your testers, no one else)

These are the basic steps. Once you have those in place you can start doing local builds and rapidly deploy them to your device for testing. In order to test In-app purchases using local builds you need to make sure of the following:

  1. The locally built APK must be signed with the same release certificate as the APK you uploaded to Google Play
  2. The locally built APK must have the same package name as the APK you uploaded (as long as you don’t change the Package field in game.project this shouldn’t be an issue)
  3. The locally built APK must have the same version code as the APK you uploaded to Google Play

With all the above in mind it simply won’t work to download dmengine.apk from d.defold.com, install it and try to use In App Purchases on Android. dmengine.apk is not signed with the same cert, it doesn’t have the same package name and not the same version code.

4 Likes