- Qt 5.15
- Qt Purchasing
- Registering Products in Google Play
- Qt 5.15.6 Reference Documentation

# Registering Products in Google Play

The Google Play market place allows you to register your application, as well as the in-app products you want to make available to it, without publishing it. The following guide gives a brief introduction on uploading your application to Google Play and registering products.

For more information, refer to the Android documentation.

## Preparing Your Application for Submission

Before you can upload your application to Google Play, you must prepare it for submission.

### Adding a Manifest XML

The default `AndroidManifest.xml` generated for applications by Qt is suitable for development testing, but cannot be used when submitting the application to Google Play.

Create your own manifest by clicking the Create Templates button in Qt Creator. You can find the button under Projects > Build tab. Expand Build Android APK to see it.

Once the manifest is added to your project, you can modify it. The most important parts are the application name and the package name. The package name must be unique, and it is recommended to follow the com.mycompany.myappname naming convention. The "com.mycompany" namespace is based on the Internet domain ownership to avoid naming collisions with other applications.

Other important parts of the manifest include the `versionCode`, which must be incremented every time you upload a new version of the application. Other properties will decide how your application package is presented in the store listing, such as the application name and the version name.

Finally, the application needs the billing permission. If you disabled Include default permissions for Qt modules from Qt Creator, you'll need to add

     <uses-permission android:name="com.android.vending.BILLING" />

to your manifest file.

For more information on the `AndroidManifest.xml`, see Android documentation.

### Signing the Application

Qt uses the default debug key to sign your application to enable running the application on a device. Same key cannot be used to sign the Application Package (APK) that is meant to be published on Google Play.

Use a private a key to sign your application to publish it on Google Play. To do so, open the Build Android APK in Qt Creator and add keystore information. When you are done, select Release as the build configuration and deploy your project.

This should create an `APK` file in the build directory of your project.

Note: Save the key used to sign the application for future use. You must sign the future versions of the application using the same key.

## Registering Your Application

Once the application is prepared for publishing, you can create a listing for it in Google Play.

The first step is to get a publisher account, if you do not already have one. Go to the Google Play developer console, log in with the Google account of your choice, and follow the steps as directed.

When you have set up your account, click on Add new application in Google Play's developer console.

Fill out as much information as you want in the store listing, and also the Pricing and distribution page.

### Publishing Your Application

In order to test in-app purchases in your application, you first have to publish it. To limit the users who can access the application before it is ready for production, it can be published as either alpha or beta, in the respective tabs on the APK page of the developer console. In order to make an alpha or beta application, fill out all the required information about the application, upload the `APK` file under the Beta testing or Alpha testing tab, and mark the application as published.

When the selected test users that you have added to your alpha or beta program purchase in-app products in your application, they will make actual purchases and will be charged for them. For testing purchases, you can register the e-mail addresses that should have testing access, under Settings in the developer console. The users with these e-mail addresses can purchase your in-app products without being charged for the purchase, and the transaction is canceled automatically at a later stage.

### Adding In-App Products

In order to access in-app products from your application, you must register them in Google Play. Go to the In-app products page and click Add new product.

Fill out the following information about your product:

- Product ID - an identifier that is used to access the product from your code.
- Product Type - Choose Managed product as this is the only type supported by the Qt Purchasing API.
- Price for the product in all the different geographical areas where it is available.

Once these details are added, Activate the product. If you have not published the application yet, the product is marked as To be activated. Otherwise, it is marked as active. The product must be activated before it can be queried from the Qt Purchasing API. If the application has recently been published, then it may take a few hours before the in-app products can be accessed from your application. Look for the Updates pending label on the top right side of the screen. If this is visible, then there are updates pending which are not yet visible from the outside.

Note: Only application packages signed with the same key used for the one in Google Play can make purchases in the application. If you want to test in-app purchases, make sure the application package is signed before you deploy and run it. It's also required that the `versionCode` of the the application is same as the package in Google Play. Upload a new package to Google Play every time the `versionCode` is updated.