Skip to content Skip to sidebar Skip to footer

Implementing In-app Billing In The Emulator

I have been reading about 'implementing In-app Billing' for an android application, and the documentation says that is not possible to test the application in the emulator. Is that

Solution 1:

Use Wifi to connect to the Internet? Testing in-app billing requires the Android Market/Google Play Store application with related Google services. This is not available on the emulator, so you need to use a real device.

Solution 2:

This is now possible since you can use Play Services in the emulator if you install the correct OS on it. You can then open Play Store on it, log in with your Google Account and then you can test the in-app purchase.

You can learn more about how to test this here. Relevant steps for setting up a device (including an emulator) can be found here.

Solution 3:

I'll post my answer if it helps anyone still stuck on this. First of all, make sure the account you will be using is publisher or test account. (More on how to set your account as publisher account check this answer by VIISHRUT MAVANII https://stackoverflow.com/a/57478895/15186237). Now...

  1. Go to AVD Manager -> Create Virtual Device
  2. Select a device that has the Play Store Icon (I use Pixel 4) and click next.
  3. Select system image that includes Google Play and has API level of 8+. (I'm not sure how target Android OS version affects this, but I don't think it matters as long as Google Play is included.) Under the "Target" column you can see the Android version and if it includes Google Play. Download that system image to use it.
  4. Click next and name it if you want. Press finish.
  5. In Android Studio, make sure you are using this new emulator. Run the emulator.
  6. Find Play Store in there and sign in with your publisher/test account.
  7. All done, run your app and test in-app billing.

Note that purchases made here using publisher/test account will not actually cost anything.

Post a Comment for "Implementing In-app Billing In The Emulator"