My app seems ready to get a 'real life' test for an in-app purchase procedure on my device. However, I receive an "The publisher cannot purchase this item" error message in Play Store. Now, how am I supposed to test this? I don't want to lose my phone's configuration by reinstalling it with a dummy account just for testing. In the Developer Console under "Settings"-"License testing", I have added my email address under "GMail accounts with testing access", but this doesn't change anything... maybe I missed some simple way, but right now it feels very confusing!
How would you test in-app purchases for a mobile application?
On selecting the device, the uploaded/selected app will automatically open in the device in question. Alternatively, you can sign in to Google Play Store, download and install a published app and test its in-app purchase feature. Just pick the Install via Google Play Store option.
How do I test in-app purchases on Android emulator?
Yes, You can test. Login into Google play with google account. Now purchase the in-app products. The purchase made in an emulator device will be a Sandbox Purchase or it will be a real purchase .
Here's an attempt to put all the requirements into one answer. This is the simplest process that worked for me:
- Set up a new Gmail account, or use an existing Gmail account that is not your developer account.
- List the email address of the test account in the Google Play Developer Console in Settings > Account Details > License Testing.
- On your device, go to Settings > Accounts, select your developer account, tap the three-dots menu, then select Remove to remove the account from the device. You can add it again later.
- Build a signed, release variant of your app.
- Upload the app as an alpha in the Play Store, publish it, and wait several hours for it to become active. Or setup an internal test channel to get the update faster.
If your device already has a debug version of the app installed, you will have to delete that. Or use this technique to run the debug and release versions in parallel (but you will still need to delete the debug version the first time). Download the release version onto your device. Apparently you can do this from the Play Store by navigating directly to the app URL, but whenever I tried this I received an "item not found" message. I uploaded the app to my own server and then downloaded it to the device from there. - Download the release version onto your device. Or use this technique to sign the release build in Android Studio from your keystore, then deploy the app onto your device from Android Studio.
- Run the release version on your device. If the alpha in the Play Store is not yet active, you'll see an error that the app version isn't configured for in-app billing. If the alpha is ready, you will be able to proceed through the test process.
- When you get to the payment screen, you will have to enter real payment information, even though you will not be charged for your purchases. I opted to use an existing PayPal account rather than add my credit card info to my Google test account.
A developer cannot purchase anything from herself. To fully test, you will need to create a test account in the Developer Console and then install your app on a device where that is the primary account. There is no other way. See http://developer.android.com/google/play/billing/billing_testing.html