Testing in-app purchases (IAPs) in your Android app can be a crucial step before releasing your app to the public. Sandbox testing is a safe and efficient way to test IAPs without charging real money to your users. In this guide, we'll walk you through the process of sandbox testing IAPs on the Google Play Store for Android.
To ensure optimal performance of your Android app, it's recommended that you test it on a real device instead of an emulator. While we have successfully tested on emulators, Google recommends using a real device.
If you do decide to use an emulator, make sure that it has Google Play installed. This will help ensure that your app is functioning properly.
To facilitate testing during later stages of development, you'll need to create a test user. This user will be the first account you log in with on your Android testing device.
Note that the primary account on an Android device can only be changed by performing a factory reset. Therefore, it's important to create a separate test user account to avoid having to perform a factory reset on your device.
Once you've created a test user account, you'll need to configure licensing testing for your app. To do this, follow these steps:
- In the Console sidebar, navigate to Setup.
- Select License testing.
- Add the account that you're using on your real device (i.e., the account you're currently logged in with) to the list.
This will allow you to configure licensing testing for your app and ensure that it's functioning properly.
In our example, we already have a list of testers:
Publish a signed version of your app to a closed track. If you haven't created a closed track yet, you can create one in the Closed testing section of the Testing menu.
Just as previously, you can use one of the existing lists or create a new one:
Press Enter, and click Save changes.
Open the Opt-in URL in your testing device to make the user a tester. You can send the URL to your device via email, for example.
Opening the opt-in URL marks your Play account for testing. If you don't complete this step, products will not load.
Check Your Application ID
Often developers will use a different application ID for their test builds. This will cause you problems since Google Play Services uses the application ID to find your in-app purchases.
Add a PIN to the test device if needed
There are cases where a test user may be allowed to purchase consumables, but not subscriptions, if the test device does not have a PIN. This may manifest in a cryptic "Something went wrong" message. Make sure that the test device has a PIN, and that the device is logged into Google Play Store.
Generate a signed APK or use Android App Bundle to upload a signed APK to the closed track you just created. You don't even need to roll out the release. Just upload the APK. You can find more information about this in this support article.
Make your release available in at least one country
If your app is new, you may need to make it available in your country or region. To do so, go to Testing > Closed testing, click on your test track, and go to Countries/regions to add the desired countries and regions.
After you've uploaded the APK, wait a few minutes for the release to process. Then, open your testing device and sign in with the email account you added to the Testers list. You can then test in-app purchases as you would on a production app.
If you run into any issues, refer to the documentation or contact Google Play Developer support.
If you are encountering this error, please follow the steps below to resolve it:
- Check if all the products have been added to Adapty Dashboard.
- Ensure that the Package Name of your app matches the one from the Google Play Store.
- Verify that the product identifiers from the app stores match with the ones you have added to the Dashboard. Please note that the identifiers should not contain the Package Name unless it is already included in the store.
- Confirm that the app paid status is active in your Google tax settings. Ensure that your tax information is up-to-date and your certificates are valid.
- Check if a bank account is attached to the app, so it can be eligible for monetization.
Also, in case some of your users have Adapty SDK with version less than 2.6, ensure that products they use are backwards compatible. Starting with SDK v2.6 this is no longer needed, so consider upgrading.
Good luck with testing your in-app purchases!
Updated 2 days ago