Guide: Google Play
Baroni last edited by Baroni
This guide explains how to create and configure in-app purchases for Google Play.
Table of Contents:
- Register developer account
- Create your app
- Publishing & testing IAP
1. Register developer account
Sign up for a Google Play developer account.
There is a $25 one-time registration fee to become a publisher on Google Play.
Having issues in the registration process? Please see this answer on Google’s support pages.
2. Create your app
In this section we will create a new app in Google Play, connect it within Unity and add some in-app purchases.
2.1 Create app in Google Play
In case you’ve opened the Developer Console for the first time, you will see an overview of actions. Start with publishing a new app.
Follow the "Set up your app" task list shown in the Dashboard and fill out all required sections.
2.2 Configuring app in Unity
If you want to test your app with the example scenes provided by Simple IAP System, you have to add them to your Build Settings. Disable the non-mobile related scenes as seen in the following screenshot, and make sure that the AllSelection scene is the first scene to load.
Switch to the Android platform (File > Build Settings) and open the Unity settings for Android by pressing Player Settings.
In the "Other Settings" section, change the bundle identifier to what you like it to be, but keep the format of com.company.appname. If you already have a published app on Google Play, make sure that the bundle identifier here is the same as displayed for your app in the Developer Console.
The bundle version and bundle version code in the Unity settings for Android will default to 1.0 / 1 for new apps, which is fine for now. If you are testing with a new app, you do not have to change this each time for every build! Just keep the 1.0 / 1 until your app is done and about to go live globally. If you’ve published an app on Google Play already, replace this with your current associated bundle version and version code from the Developer Console.
If you didn’t publish an app before, you probably didn’t create a Keystore yet. To do so, scroll down in the settings for Android and expand the Publishing Settings. Click on "Keystore Manager" in order to create a new key. Save this Keystore somewhere safe! If you lose your Keystore, you cannot submit app updates in Google Play anymore. If you would like to use an existing Keystore, choose "Custom Keystore" instead.
On the Google Play dashboard, the bundle identifier will be displayed on the application overview once you've uploaded an APK. When exporting the build, note that "Development Build" needs to be unchecked, even if we are going to upload it to a testing track later. We are only going to save the build created in this process on the hard drive (and not using Build And Run), because Google Play still needs some settings to be configured first.
2.3 Entering app details
Open the "Release" section and upload your exported build to the Closed (Alpha), Open (Beta) or Internal Testing track. For this guide we choose the Internal testing track.
After creating and uploading a release, specify your tester's emails for this app. The list of tester emails can be re-used for different apps. However if you only have a few people testing your app (e.g. only developers or yourself), you can add their addresses to the "All Apps > Settings > License testing" section. To test in-app purchases, you will have to add an email address which is NOT the email used to register your Google Play Developer account and then add this email on your device. Otherwise, you will get the error message "The publisher cannot purchase this item".
2.4 Create in-app purchases
Open our IAP Settings editor in Unity and define your IAPs (Create Product > In App Purchase, Type = Currency or Default). For a definition of Non-Consumable, Consumable and Subscription product types please refer to Google's documentation.
In Google Play's "Monetise > Products > In-app products / Subscriptions" section, add the same products with the exact same product identifier (ID). Consumable and non-consumable products go into the "In-app products" tab, whereas subscription products are in a separate tab. Only active products can be purchased. Note: If you add translations for your products, Simple IAP System is able to display product details in the user’s native language, which naturally increases IAP conversion rates (recommended).
At this point, you should now have the exact same product identifiers available in Google Play and in our IAP Settings editor.
3. Testing IAPs
Don’t worry: because you’ve uploaded an internal, alpha or beta build, the app will not be visible publicly – only for you to test it. The release process can take up to 24 hours before your app is available for testing.
After you've waited the ~24 hour processing times for your app on Google Play, on the dashboard you should find a "View on Google Play" link, that is correctly displaying the store page.
If you chose a testing track previously, the "Release > Testing > Testers" page displays a link to subscribe for testing. Open it with the corresponding Gmail account you invited (that is not the Google Play admin account) and join the testing program.
Go back to Unity and open the Build Settings. First, enable Development Build. This enables log messages sent by Simple IAP System on your device for debug purposes. Don’t forget to disable Development Build for your live apps. Finally press "Build And Run" to deploy your project to your connected Android device. If you change values in the IAP Settings window of Simple IAP System later, you need to uninstall your app from the device before deploying it again (so that any locally cached product data is wiped).
When the app has started on your device, enter your shop scene and try to purchase a product. Log in with your test account when prompted. If it does not prompt for your Google Play account, go to your Google Play device settings and disable automatic password completion in the authentication options. Purchasing a product in your app should show a popup similar to this one:
Baroni last edited by Baroni
If you can’t see any products or if the purchase popup does not show up at all, you may have some issues with your Unity/Google Play settings and/or errors on the device. Please verify that all of the following points have been met:
- app bundle identifier in Unity matches the app identifier in Google Play
- app is released on an internal, alpha or beta track in Google Play (draft apps do NOT work!)
- in-app product identifiers in the SIS IAP Settings editor matches the IAP identifiers created in Google Play
- in-app product are active in Google Play
- you have added test user accounts in Google Play and joined the testing program
- you are logged in with a Google Play the associated test user account on the device
Still having issues? You could install CatLog (could require root access) for reading the device log over your USB connection, or do it manually . In both cases, filter for Unity messages to remove any irrelevant events. For debugging via your pc, open a command prompt and navigate to the adb.exe on your hard drive (located where you installed the Android SDK > platform-tools directory). Next, enter adb.exe logcat –s Unity to start the debugging connection. Run your app on the device again and watch out for errors!
Please note that in case of issues with this process, I am not able to guess or remotely debug the exact cause for you. Since a major part of this guide is not written for Simple IAP System in particular, there is a high chance that your issue has been experienced by many, many other developers before and is covered somewhere already - debug your device, do a Google search for the error message and look out for popular Android developer or Unity IAP threads!