/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia.  For licensing terms and
** conditions see http://qt.digia.com/licensing.  For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
** this file.  Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: http://www.gnu.org/copyleft/fdl.html.
** $QT_END_LICENSE$
**
****************************************************************************/


/*!
    \page platform-notes-android.html
    \title Platform and Compiler Notes - Android
    \contentspage Platform and Compiler Notes

    This page contains information particular to building Qt applications for
    and running them on the \l{Qt for Android}{Android} platform. Qt supports
    Android versions 2.3.3 (API level 10) or later.

    \tableofcontents

    \section1 Android Development in Qt Creator

    The easiest way to develop with Qt for Android is to use
    \l{http://qt-project.org/doc/qtcreator/creator-developing-android.html}{Qt Creator}. When you apply
    a \b{Qt for Android Kit} to a Qt Creator project, it will create and maintain a set of files which
    are required to make your application run on Android.

    The files added to your project are:
    \list
    \li \e .java files will serve as the entry point into your application and
    automatically load Qt to execute the native code in your application
    \li \e AndroidManifest.xml which provides meta-information about your
    application
    \li Other XML files detailing the dependencies of your application
    \li Resource files
    \li Depending on the deployment method selected in Qt Creator, additional
    files like libraries and QML files can be included in the project.
    \endlist

    Qt Creator adds these files in a subdirectory of your project called \b android. The contents of
    the \b android folder is used as basis for your app's distributable application package.

    \section1 Application Package

    On Android, apps are distributed in packages called \e APK. Qt Creator
    builds the \e APK for you, but if you for some reason want to do this
    manually, you must first make sure that the appropriate packaging and build
    files are in place. For more detailed information about how the packaging
    is done, see \l{Deploying an Application on Android}.

    \section1 Deployment

    Qt Creator currently supports three methods of deployment for Android apps: the default
    deployment method is suitable for distribution of the APK file. With this deployment method,
    the necessary Qt libraries and files will be copied into your project directory, and bundled
    as part of the APK, so that you get a stand-alone, distributable application package.

    \section2 Deployment with Ministro
    The second method is suitable if you want to minimize the size of your APK, and can be selected by
    opening the \b Run settings of your project, expanding \b{Deploy Configurations} and removing the
    tick from the \b{Use local Qt libraries} check box. In this case, your application will have an
    external dependency called \b{Ministro}. If a user downloads your application, and it is the first
    application on their device to depend on Ministro, they will be asked to install it before they can
    run your application. Ministro downloads Qt libraries from a repository of your choice. The
    repository URL can be set by editing the file \e{android/res/values/libs.xml} which is created by Qt
    Creator when configuring your project. Ministro will then serve as a central repository for Qt
    libraries, and several apps can share the libraries to limit the amount of duplication. Note that
    using this deployment method requires a repository for the libraries you want to distribute.

    \section2 Deployment for Debugging
    The third method is more convenient when you are simply testing your application on a device
    physically connected to your development machine (or an emulator). It will copy the Qt libraries
    into a temporary directory on your device and run the application against these instead. An APK
    built in this way is not distributable, since it relies on the device being prepared to contain
    the Qt libraries in the correct location. However, since the Qt libraries are only copied into
    the device once, it benefits from a faster turn-around time, so it's more suited for testing
    changes to your application during development. This deployment method can be selected by
    opening the \b Run settings of your project, expanding \b{Deploy Configurations} and choosing
    \b{Deploy local Qt libraries}. Make sure the \b{Use local Qt libraries} check box is also ticked.

    \section1 Plugins and Imports Special Considerations

    If an application uses plugins or imports that depend on other modules, these modules have to
    be listed in the application's dependencies. This is because Qt Creator does not know ahead
    of time which imports or plugins your application will end up loading.

    For example, if your application's QML code imports \l{Qt Multimedia}, then the Qt Multimedia module
    must explicitly be made a dependency of the application. You can do this by adding it to the
    application .pro file:

    \code
    QT += multimedia
    \endcode

    It is also possible to manually enable dependencies on Qt libraries by opening the
    \gui Run settings of your project, expanding \gui{Package configurations} and selecting the
    \gui Libraries tab. Manually check the libraries that are dependencies of your project.

    \section1 Text Special Considerations

    Because of a bug in some OpenGL drivers, the mechanism used by Qt to cache text glyphs does
    not work as expected on all Android devices, causing text to appear scrambled. To remedy this,
    a workaround is in place, which increases memory consumption and can also affect text rendering
    performance. Before Qt 5.3.2, the workaround was enabled only for a particular set of devices.
    It is now used by default on all devices.

    You can disable the workaround by setting the \c QT_ANDROID_DISABLE_GLYPH_CACHE_WORKAROUND
    environment variable to \c 1. You should do so only after verifying that text appears correctly
    on all targeted devices.

    \section1 OpenGL Special Considerations

    Qt for Android provides two separate platform plugins: One which is suited for traditional
    \l{Qt Widgets}{widget-based} apps that do not require OpenGL support, and one which will be used
    when OpenGL is required. When building and deploying your app, Qt Creator will detect whether the
    OpenGL-enabled plugin is required by checking if your app depends on either the \l{Qt OpenGL}
    module or the \l{Qt Quick} module.

    There are some special considerations to be made when the OpenGL-enabled platform plugin is in
    use. The plugin only supports full screen top-level windows. This means that even dialogs and popups
    will be shown as full screen. There may also be drawing errors if you try to stack windows that
    have animations or otherwise require updating their UI while they are obscured by another window.

    It is recommended that you try to avoid multiple top-level windows in the case of Android apps, as
    there is no traditional window system on this platform.

    \note Embedding a QGLWidget inside a widget hierarchy is not supported. When QGLWidget is in use,
    it must be the top-level widget.

    \section1 Multimedia Special Considerations

    \l{Qt Multimedia}, like the rest of Qt, supports Android versions 2.3.3 (API level 10) or later.
    There is however an exception for video output which requires Android versions 3.0 (API level 11)
    or later. This affects camera preview and video player features.

    Additionally, the \l{Qt Multimedia Widgets} module is not supported on Android, which means
    video display is only available using the VideoOutput and \l{QtMultimedia::Video}{Video} QML items.

    \section1 Assets File System

    Qt for Android provides a special, virtual file system which is based on the \e assets mechanism
    in Android. Files that are put under \e assets in the \e android folder created by Qt Creator, will
    be packaged as part of your application package. These can be accessed in Qt by prefixing the paths
    with \c{assets:/}. For instance, to access the image \e logo.png in the folder \e{assets/images},
    you can use \c QPixmap("assets:/images/logo.png").

    If using the assets mechanism is not required for your app, the recommended way of distributing
    resources with your Qt app is to use \l{the Qt Resource System}, which is a cross-platform mechanism
    for distributing resources with your app.

    \section1 Supported Architectures

    Qt for Android currently has binaries for ARMv7 and x86. Make sure you select the
    correct architecture for the device or emulator you are targeting, otherwise your application
    will crash. The MIPS archictecture is currently not supported by Qt.

    If you want to support several different architectures in your application, the recommendation is
    to build separate APKs for each architecture, so that each APK only contains the binaries required
    for the targeted architecture. For more information about this, see the Android documentation
    about \l{http://developer.android.com/google/play/publishing/multiple-apks.html}{Multiple APK Support}.
*/
