// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only

/*!
\page android-publishing-to-googleplay.html
\title Publishing to Google Play
\brief Provides instructions to prepare your application for publishing.
\ingroup android-platform-extra-topics
\previouspage android-3rdparty-libs.html
\nextpage Supporting Google Emoji Font Policy

\l{Qt for Android} provides a complete solution to develop, build, and package
your applications for Android. Most of these tasks, especially packaging and
deployment, are handled by Qt Creator, providing a rich developer experience.

Every time you run the application using Qt Creator, an Android Application
Package (APK) is created and deployed onto the target of your choice
(device or emulator). With a few minor changes to packaging settings, you can
publish your application on Google Play.

\section1 Building the App

Once your app has been developed and you want to move forward to publish it
to Google Play, follow these instructions to create an \c{.apk} or \c{.aab}
that can go live on Google Play:

    \list 1
        \li Open your project with Qt Creator choosing a \c{Release Build}.

        \li Select \uicontrol Projects > \uicontrol Build > \uicontrol {Build Android APK}
        > \uicontrol {Create Templates} to create the Android package template files
        such as \c{AndroidManifest.xml}, which is the main file of concern here.

        \li Check for the following settings in \c{AndroidManifest.xml}:
        \list
            \li Set \uicontrol{Application name} and \uicontrol{Application icon}.
            \li Set the app's name using \c {android:label} under the manifest's
            \c application section.
            \li Set the app's version code and name via CMake's properties
            \l {QT_ANDROID_VERSION_NAME} and \l {QT_ANDROID_VERSION_CODE}.
            For qmake, use \l {ANDROID_VERSION_NAME} and \l {ANDROID_VERSION_CODE}.
            For qmake, we will use \l {ANDROID_VERSION_CODE} below, to work around
            publishing multi-ABIs apps.
        \endlist

        See \l{Qt for Android Manifest File Configuration} for more information.

        \li Set \c minimum and \c{target} SDK versions according to your app's needs.
        This can be done using the CMake properties \l QT_ANDROID_TARGET_SDK_VERSION
        and \l QT_ANDROID_MIN_SDK_VERSION. Or for \c qmake \l ANDROID_TARGET_SDK_VERSION
        \l ANDROID_MIN_SDK_VERSION.

        \note As before with Qt 5.15, you can specify these settings in the
        \c {AndroidManifest.xml}. Be aware that the CMake and qmake properties
        mentioned above will override these if set there. See \l{Android: App Versioning}
        for more information on setting these in \c build.gradle.

        \li Set up a \l{Android: Android keystore system}{keystore} to sign your
        package. You can create a new keystore if you do not have one. For more
        information, see \l{Qt Creator: Specifying Settings for Packages}
        {Signing Android Packages}.

        \li Locate the generated package:

        \list
        \li For APK packages, locate the \c{.apk} package at:

            \badcode
            <build_path>/android-build/build/outputs/apk/release/android-build-release.apk
            \endcode

            \note In Qt Creator, select \uicontrol{Projects} > \uicontrol{Build}
                > \uicontrol{Build Steps} > \uicontrol{Build Android APK} >
                \uicontrol{Open package location after build} to build the
                application's \c{.apk} and open the directory containing the
                package.

        \li For AAB packages, select \uicontrol{Projects} > \uicontrol{Build}
            > \uicontrol{Build Steps} > \uicontrol{Build Android APK} >
            \uicontrol{Build .aab (Android App Bundle)} for Qt Creator to generate
            the \c{.aab} file, then locate the package at:

            \badcode
            <build_path>/android-build/build/outputs/bundle/release/android-build-release.aab
            \endcode

        \endlist
    \endlist

\section1 Uploading the App to Google Play Store

    Log into the \l{Google Play Developer Console} and upload the \c{.aab} files,
    along with a description and screen captures resembling the usage of your application.

    \section2 Multi-ABI Bundles

    Uploading one \c {.aab} with all the supported architectures is enough for
    Qt versions that support building a multi-ABI bundle. Qt \QtVer supports
    building multi-ABI bundles with \b only with CMake. For more information,
    see \l {QT_ANDROID_ABIS}.

    \section2 Single-ABI bundles

        However, publishing your app requires additional steps for Qt versions
        that don't have the multi-ABI build support. \c qmake builds in Qt \QtVer
        fall into this category.

        To publish your app that is built using a single ABI kit, you need
        to make sure that each ABI uses a different internal version code.
        The version code is an internal non-public identifier for your app's
        release. Build each one of the architectures you want to support
        and set a different version code for each ABI. This can be done
        as follows for qmake:

        \badcode
        ANDROID_VERSION_CODE = <unique_version>
        \endcode

        The app developer can use a specific scheme for the version code. For example,
        the code could have chunks for the platform, the ABI, and the actual
        version. Then, a sample scheme would be \c {<Platform><ABI><AppVersion>}:

        \list
        \li Platform:
            \list
                \li 1 for Arm
                \li 2 for Intel
            \endlist
        \li Architecture:
            \list
                \li 32 for 32 bit
                \li 64 for 64 bit
            \endlist
        \endlist

        The resulting version code for release 1.0 for arm64-v8a ABI,
        would be \c {16410}.

        For more information, see Google's documentation on
        \l {Android: App Versioning}{app versioning}.

        The following screenshot shows an example of an app targeting 4 ABIs,
        while each package uses a unique version code, which is different from
        the version name that is the public version string.

        \image android-single-abis.png

    \sa {Deploying an Application on Android}.
*/
