10

Is it possible to disable in-app billing/purchase and test my application on an Android Emulator? I want to do some functional testing of my application on multiple emulators. Later on I would test the 'in-app billing' on a real device.

Anyone have experience? How should I do this?

From Google: http://developer.android.com/guide/market/billing/billing_testing.html

To test in-app billing in an application you must install the application on an Android-powered device. You cannot use the Android emulator to test in-app billing. The device you use for testing must run a standard version of the Android 1.6 or later platform (API level 4 or higher), and have the most current version of the Android Market application installed.

Update 2022

Recently re-checked:

  • Even if we Emulate a system-image which targets Google-Play (instead of Google APIs),
  • update Google-play services to latest,
  • and follow the "Goole Wallet" app's and/or "Google Pay" app's add-credit-card form till end successfully.

Said App instead of adding credit-card as payment-method, just shows message:

screen-shot

Note that the message is confusing, as we were trying to add credit-card, and did not try to use "Tap to Pay".

Top-Master
  • 7,611
  • 5
  • 39
  • 71
Dimitri Dewaele
  • 10,311
  • 21
  • 80
  • 127
  • Did you try to just run the app on an emulator? As long as you aren't trying to use the in-app billing functionality there shouldn't be any issue. Your app should also be able to detect if in-app billing is available and still function (in a limited fashion) if not. – cygery Sep 29 '14 at 12:45
  • I tried it, but the app doesn't work on an emulator, since it depends on google services. – Dimitri Dewaele Sep 29 '14 at 14:37
  • Use an AVD with Google APIs (see [documentation](http://developer.android.com/google/play-services/setup.html)). – cygery Sep 29 '14 at 15:41
  • The problem is that the app does not start up in de AVD, since this AVD is not a real device and the app needs to communicate with real google services, attached to a real google account. In-App billing checks what services that the user already own/has bought. – Dimitri Dewaele Sep 30 '14 at 06:55
  • As described in the documentation I linked above you have to check for availability of Google Play Services. Anyway, it also says that an AVD with Google APIs running Android 4.2.2+ can be used to test them. I'm not sure about the requirement of a Google account. You should try to disable all in-app billing functionality when running in an emulator, e.g., using dynamic [checks](http://stackoverflow.com/questions/2799097/how-can-i-detect-when-an-android-application-is-running-in-the-emulator). – cygery Sep 30 '14 at 10:22

1 Answers1

5
  1. Install an emulator that has already google playstore installed, on a system image that supports google service api

My emulator spec:

Pixel 3a API 31
ABI: x86_64
System image: Android API 31 (Google Play)
  1. Create a closed testing track in google playstore console

  2. Add your gmail to license testing and closed testing email list

  3. Wait for your closed testing to be approved and available for testers.

  4. If you're using an existing emulator, please wipe data and cold boot

  5. Login as a tester account in gmail app as the first thing when you launch the emulator

  6. Browse closed testing invitation url, and accept invitation to take part in closed testing track

  7. IMPORTANT Make sure you're using the same application id (e.g. com.your.company.app), version code (e.g. 1.3.0) and version name(a.k.a build number) as the closed testing binary.

  8. That's all. Test payments in the emulator.

For step 2 ~ 4 you can refer to this wonderful doc from revenue cat: https://docs.revenuecat.com/docs/google-play-store

glinda93
  • 7,659
  • 5
  • 40
  • 78