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 in Google Play
- Set up Google Merchant account
- Android deployment in Unity
- Upload & publish your app in Google Play
- Testing IAPs on your device
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 Google Play
In this step we will create a new app in Google Play with in-app purchases.
2.1 Create app
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.
Fill out the required fields (with your app title) and press on “Prepare Store Listing”. We will upload an APK later.
Fill out all required fields, upload some screenshots (you can use blank images/templates) and save your listing. The checkmark next to the Store Listing tab will be highlighted in green after you have entered every information necessary.
2.2 App pricing
Do the same with the Content Rating tab, by going through the wizard provided and complete the content rating questionnaire.
Next, switch to the Pricing & Distribution tab and specify your desired app pricing strategies. After this step, both Content Rating and Pricing tabs should be highlighted in green.
2.3 Create in-app purchases
In the In-app Products tab, add a new product.
Add a new managed product (for consumable and non-consumable products) or subscription to your app. The Product ID is a unique identifier for this in-app purchase, which you have entered in Simple IAP System’s IAP Settings editor (e.g. coins, no_ads etc.).
Enter the required fields for declaring this in-app purchase. Afterwards, press save and set the product to Active.
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 IAP information available in Google Play and in our IAP Settings editor.
3. Set up Google Merchant account
To sell priced apps and in-app purchases, you will need a Google Merchant account to receive payments. Google Merchant supports various countries and can be configured right in the Google Play Developer Console. For a detailed list of supported countries and steps to do, please see this entry on Google’s support pages.
4. Android deployment in Unity
Here we will prepare our application in Unity for the Android platform.
4.1 Enter Google Play license key
Your license key is the unique identifier for your app and prevents unauthorized access. You can find it in the Google Play Developer Console, under All applications > Services & APIs.
Copy the full key and switch to the Unity project. Locate the IAPManager prefab in the project panel (Simple IAP System > Prefabs > Resources) and insert this license key into the Google Store Key field.
If you are using a 3rd party billing plugin, it is very likely that you cannot find this field on the IAPManager prefab. In this case, please open the settings window of the billing plugin you are using and enter the key there. Here is an overview of where they key field is located:
Unity IAP: IAPManager prefab
Prime31: IAPManager prefab
Voxel Busters: Window > Voxel Busters > NativePlugins > Select NPSettings. Billing Settings > Android > Public Key.
Stan's Assets: Window > Stan's Assets > Android Native > Edit Settings. Billing Settings (third tab) > Base 64 Key.
SOOMLA: Window > Soomla > Edit Settings. Android Settings > Billing Service Selection > Google Play > API Key.
4.2 Enter bundle identifier
Switch to the Android platform (File > Build Setting) 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 an app on Google Play, make sure that the bundle identifier here is the same as displayed for your app in the Developer Console.
4.3 Check bundle version
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’ve published an app on Google Play already, replace this with their associated bundle version and version code from the Developer Console (on the APK section).
4.4 Modify AndroidManifest (3rd party billing plugins only)
You can skip this step if you are using Unity IAP.
3rd party billing plugins usually come with an AndroidManifest.xml file, which contains necessary Android activities and permissions used by the plugin – such as android.permission.INTERNET, com.android.vending.BILLING and so on. These are displayed when the user tries to install your application on his device. After importing such an Android plugin, the AndroidManifest.xml file would be located under Plugins > Android in your project panel. All of our supported billing plugins are modifying this file automatically for you, you only have to make sure that billing is enabled in the plugin you are using.
4.5 Create Keystore
If you didn’t publish an app before, you probably didn’t create a Keystore yet. To do so, open the Unity settings for Android (File > Build Settings > Player Settings) and expand the Publishing Settings. Enable Create New Keystore, enter your password (twice) below and in the Key Alias, select Create a new key. A new window opens – enter the necessary information. 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 Browse Keystore and enter your Keystore password, then select the Alias and enter the same password again.
4.6 Build app
Build your app by pressing Build (File > Build Settings). We are only going to save the APK file 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.
5. Upload & publish your app in Google Play
5.1 Upload APK
Go to the APK section in Google Play and upload your newly created APK file in the Alpha testing stage.
5.2 Publish app
After filling out each tab and uploading the APK, each section should be completed (green) and the status shown as Ready to publish.
You are now ready to publish your app. Don’t worry: because you’ve uploaded an alpha or beta build, the app will not be visible publicly – only for you to test it. Select the status and choose Publish this app. The publishing process can take up to 24 hours before it is available for your testing needs.
5.3 Add test accounts
Under Settings, go to the Account details tab and add your Gmail account for testing access. 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".
6. Testing IAPs on your device
After you've waited the ~24 hour submission approval for your app on Google Play, go back to Unity and open the Build Settings (File > 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. Next, if you want to test your app with the example scenes, you have to add them to your Build Settings. Finally press Build And Run to deploy your project to your connected Android device. If you change values in the IAP Settings editor of Simple IAP System later, you need to uninstall your app from the device before deploying it again.
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 the following popup:
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:
Google developer key is present on IAPManager prefab
- app bundle identifier in Unity matches the app identifier in Google Play
- app is published as alpha or beta in Google Play (draft apps do NOT work!)
- in-app purchase identifiers in the SIS IAP Settings editor matches the IAP identifiers created in Google Play
- in-app purchases are published in Google Play
- you have added test user accounts in Google Play
- you are logged in with a Google Play 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!