3

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 true?

I don't have a "mobile data plan" with the mobile I'm developing, so I try to connect the mobile through my PC via USB, but because my PC is behind a proxy, I can't connect to Internet.

What could I do?

Thanks in advance

Eduardo
  • 1,169
  • 5
  • 21
  • 56

3 Answers3

6

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.

Nikolay Elenkov
  • 52,576
  • 10
  • 84
  • 84
  • +1 Proper solution. But, can we install `Market` in emulator. So, after that we can use the in-app billing in Emulator. Is that possible? – Praveenkumar Jun 14 '12 at 07:37
  • Not really. As I said, Market is not a single application, it depends on the Google services infrastructure. This is not available on the emulator. You would probably find people who have tried though, usually with mixed results. Not worth the trouble. – Nikolay Elenkov Jun 14 '12 at 07:42
  • [Will this useful to the user?](http://www.tech-recipes.com/rx/10004/accessing-android-market-from-android-sdk/) – Praveenkumar Jun 14 '12 at 07:45
4

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.

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.

Sharp
  • 1,335
  • 1
  • 12
  • 27