2016-01-15 14:51:16 +01:00
|
|
|
/****************************************************************************
|
2012-07-24 15:31:23 +02:00
|
|
|
**
|
2017-07-31 13:28:49 +02:00
|
|
|
** Copyright (C) 2017 The Qt Company Ltd.
|
2016-01-15 14:51:16 +01:00
|
|
|
** Contact: https://www.qt.io/licensing/
|
2012-07-24 15:31:23 +02:00
|
|
|
**
|
2016-01-15 14:51:16 +01:00
|
|
|
** This file is part of the Qt Creator documentation.
|
2012-07-24 15:31:23 +02:00
|
|
|
**
|
2016-01-15 14:51:16 +01:00
|
|
|
** 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 The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2012-07-24 15:31:23 +02:00
|
|
|
**
|
2016-01-15 14:51:16 +01:00
|
|
|
** GNU Free Documentation License Usage
|
2012-07-24 15:31:23 +02:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Free
|
|
|
|
|
** Documentation License version 1.3 as published by the Free Software
|
2016-01-15 14:51:16 +01:00
|
|
|
** 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: https://www.gnu.org/licenses/fdl-1.3.html.
|
2012-07-24 15:31:23 +02:00
|
|
|
**
|
2016-01-15 14:51:16 +01:00
|
|
|
****************************************************************************/
|
2012-07-24 15:31:23 +02:00
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
|
2014-03-17 12:18:12 +01:00
|
|
|
\contentspage {Qt Creator Manual}
|
2012-09-07 16:15:58 +02:00
|
|
|
\previouspage creator-deployment.html
|
2012-07-24 15:31:23 +02:00
|
|
|
\page creator-deploying-android.html
|
2015-04-24 10:31:27 +02:00
|
|
|
\nextpage creator-deployment-embedded-linux.html
|
2012-07-24 15:31:23 +02:00
|
|
|
|
|
|
|
|
\title Deploying Applications to Android Devices
|
|
|
|
|
|
2014-11-17 15:54:00 +01:00
|
|
|
On Android, applications are distributed in a specially structured type of
|
|
|
|
|
ZIP package called an APK. \QC supports the following methods of deployment
|
|
|
|
|
for Android applications:
|
2013-05-06 15:19:04 +02:00
|
|
|
|
|
|
|
|
\list
|
|
|
|
|
|
|
|
|
|
\li As a stand-alone, distributable application package (APK).
|
|
|
|
|
|
|
|
|
|
\li As a minimal APK that contains a dependency to the Ministro tool.
|
|
|
|
|
The Ministro tool downloads the necessary Qt libraries from a
|
|
|
|
|
repository of your choice.
|
|
|
|
|
|
|
|
|
|
\li As an incomplete APK that is suitable for testing and debugging
|
|
|
|
|
applications on a device connected to the development host. The APK
|
|
|
|
|
relies on the device containing the Qt libraries in the correct
|
|
|
|
|
location. \QC copies the libraries to that location the first time
|
|
|
|
|
you deploy the application.
|
|
|
|
|
|
|
|
|
|
\endlist
|
|
|
|
|
|
2014-12-11 15:43:19 +01:00
|
|
|
To specify settings for application packages, select \uicontrol Projects >
|
|
|
|
|
\uicontrol {Build Android APK} > \uicontrol Details.
|
2013-05-06 15:19:04 +02:00
|
|
|
|
2017-07-31 13:28:49 +02:00
|
|
|
For more information about options that you have for running applications,
|
|
|
|
|
see \l {Specifying Run Settings for Android Devices}.
|
|
|
|
|
|
2013-10-31 14:35:05 +01:00
|
|
|
\section1 Creating Distributable APK Packages
|
2012-07-24 15:31:23 +02:00
|
|
|
|
2013-05-06 15:19:04 +02:00
|
|
|
To copy Qt libraries and files to the project directory and to bundle them
|
2014-12-11 15:43:19 +01:00
|
|
|
as part of the APK, select the \uicontrol {Bundle Qt libraries in APK} option.
|
2013-05-06 15:19:04 +02:00
|
|
|
|
2014-11-20 17:15:32 +01:00
|
|
|
\note Android 5 devices support only this option.
|
|
|
|
|
|
2013-05-06 15:19:04 +02:00
|
|
|
\section1 Using Ministro to Install Qt Libraries
|
|
|
|
|
|
|
|
|
|
To minimize the size of your APK, you can package the application with an
|
|
|
|
|
external dependency called Ministro. If a user downloads your application,
|
|
|
|
|
and it is the first application on their device to depend on Ministro, they
|
|
|
|
|
are asked to install Ministro before they can run your application.
|
|
|
|
|
|
|
|
|
|
Ministro serves as a central repository for Qt libraries. This enables
|
|
|
|
|
several applications to share the libraries, which only need to be installed
|
|
|
|
|
once. To use this deployment method, you must set up a repository for the
|
|
|
|
|
libraries that you want to distribute. To specify the
|
|
|
|
|
repository URL, edit the file \c {android/res/values/libs.xml}, which is
|
|
|
|
|
created by \QC.
|
|
|
|
|
|
|
|
|
|
To use Ministro to install the Qt libraries, select the
|
2014-12-11 15:43:19 +01:00
|
|
|
\uicontrol {Use Ministro service to install Qt} option.
|
2013-03-04 13:21:27 +01:00
|
|
|
|
2013-05-06 15:19:04 +02:00
|
|
|
\section1 Deploying Qt Libraries for Debugging
|
|
|
|
|
|
|
|
|
|
To test your application on a device that is physically connected to the
|
|
|
|
|
development host (or on an emulator), you can copy the Qt libraries into a
|
|
|
|
|
temporary directory on your device and run the application against them.
|
|
|
|
|
|
|
|
|
|
An APK built in this way is not distributable, since it relies on the device
|
|
|
|
|
containing the Qt libraries in the correct location. However, as the Qt
|
|
|
|
|
libraries are only copied into the device once, this method provides a fast
|
|
|
|
|
turn-around time, and is therefore convenient for testing the application
|
|
|
|
|
during development.
|
|
|
|
|
|
2014-12-11 15:43:19 +01:00
|
|
|
Select the \uicontrol {Deploy local Qt libraries to temporary directory} option to
|
2013-10-31 14:35:05 +01:00
|
|
|
deploy Qt libraries to the \c{/data/local/tmp/qt} folder on the device and
|
|
|
|
|
to run the application against them.
|
2012-07-24 15:31:23 +02:00
|
|
|
|
2014-04-16 17:05:35 +02:00
|
|
|
\section1 Packaging Applications
|
2013-10-31 14:35:05 +01:00
|
|
|
|
2014-04-16 17:05:35 +02:00
|
|
|
Because bundling applications as APK packages is not
|
|
|
|
|
trivial, Qt 5 provides a deployment tool called \c androiddeployqt.
|
2014-12-11 15:43:19 +01:00
|
|
|
When you deploy an application using a \uicontrol {Qt for Android Kit}, \QC uses
|
2014-04-16 17:05:35 +02:00
|
|
|
the \c androiddeployqt tool to create the necessary files and to bundle them
|
|
|
|
|
into an APK:
|
2013-10-31 14:35:05 +01:00
|
|
|
|
|
|
|
|
\list
|
|
|
|
|
|
|
|
|
|
\li Java files, which serve as the entry point into your application and
|
|
|
|
|
that automatically load Qt and execute the native code in your
|
|
|
|
|
application.
|
|
|
|
|
|
|
|
|
|
\li AndroidManifest.xml, which provides meta-information about your
|
|
|
|
|
application.
|
|
|
|
|
|
|
|
|
|
\li Other XML files, which specify the dependencies of your application.
|
|
|
|
|
|
|
|
|
|
\li Resource files.
|
|
|
|
|
|
|
|
|
|
\li Libraries and QML files, which can be included in the project
|
|
|
|
|
depending on the deployment method that you select.
|
|
|
|
|
|
2014-09-22 16:45:14 +02:00
|
|
|
\li Gradle wrappers that are needed to download and use Gradle.
|
|
|
|
|
|
|
|
|
|
\li Gradle script that is needed by Java IDEs, such as Android Studio.
|
|
|
|
|
It allows the user to extend the Java part without copying our Java
|
|
|
|
|
sources. It also allows the IDEs to provide code completion, syntax
|
|
|
|
|
highlighting, and so on.
|
|
|
|
|
|
2013-10-31 14:35:05 +01:00
|
|
|
\endlist
|
|
|
|
|
|
2015-08-06 12:53:03 +02:00
|
|
|
The Gradle wrappers and scripts are bundled only if you use
|
|
|
|
|
\l{Selecting the APK Build Tool}{Gradle} to build the application packages.
|
2014-09-22 16:45:14 +02:00
|
|
|
|
2013-10-31 14:35:05 +01:00
|
|
|
To view the packages that the \c androiddeployqt tool created, select the
|
2014-12-11 15:43:19 +01:00
|
|
|
\uicontrol {Open package location after build} check box.
|
2013-10-31 14:35:05 +01:00
|
|
|
|
|
|
|
|
The packages are deployed on the connected Android devices. To switch the
|
|
|
|
|
device used as a default device for the selected kit, select
|
2014-12-11 15:43:19 +01:00
|
|
|
\uicontrol Projects > \uicontrol Run >
|
|
|
|
|
\uicontrol {Reset Default Devices}. The setting applies until you restart \QC.
|
2013-10-31 14:35:05 +01:00
|
|
|
For more information, see \l{Selecting Android Devices}.
|
|
|
|
|
|
|
|
|
|
For more information about the \c androiddeployqt tool, see
|
2013-11-25 17:37:19 +01:00
|
|
|
\l{Deploying an Application on Android}.
|
2013-10-31 14:35:05 +01:00
|
|
|
|
2014-04-16 17:05:35 +02:00
|
|
|
\section2 Specifying Settings for Packages
|
2013-10-31 14:35:05 +01:00
|
|
|
|
|
|
|
|
You can specify settings for the \c androiddeployqt tool in \QC and in the
|
2014-12-11 15:43:19 +01:00
|
|
|
project .pro file. To specify settings in \QC, select \uicontrol Projects >
|
|
|
|
|
\uicontrol {Build Android APK} > \uicontrol Details.
|
2013-10-31 14:35:05 +01:00
|
|
|
|
|
|
|
|
\image qtcreator-android-deploy-configurations.png "Deploy configurations"
|
|
|
|
|
|
|
|
|
|
The anddroiddeployqt tool uses the information in the project .pro file to
|
|
|
|
|
create APKs. For more information about the qmake variables
|
|
|
|
|
that you can set in the .pro file to tailor the APK, see
|
2015-01-07 11:34:44 +01:00
|
|
|
\l{Deploying an Application on Android}.
|
2013-10-31 14:35:05 +01:00
|
|
|
|
|
|
|
|
You can view information about what the anddroiddeployqt tool is doing in
|
2014-12-11 15:43:19 +01:00
|
|
|
the \uicontrol {Compile Output} pane. To view additional information, select the
|
|
|
|
|
\uicontrol {Verbose output} check box.
|
2013-10-31 14:35:05 +01:00
|
|
|
|
|
|
|
|
\section3 Selecting API Level
|
|
|
|
|
|
2014-12-11 15:43:19 +01:00
|
|
|
In the \uicontrol {Android build SDK} field, you can select the API level to use
|
2013-10-31 14:35:05 +01:00
|
|
|
for building the application. Usually, you should select the newest API
|
|
|
|
|
level available.
|
|
|
|
|
|
|
|
|
|
This field does not specify the minimum supported API level nor the target
|
|
|
|
|
API level, which you can specify in the Android manifest file.
|
|
|
|
|
For more information about Android API levels, see
|
|
|
|
|
\l{http://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels}
|
|
|
|
|
{What is API Level?}.
|
|
|
|
|
|
|
|
|
|
\section3 Signing Android Packages
|
|
|
|
|
|
2014-11-18 11:36:38 +01:00
|
|
|
To publish your application, you must sign it by using a \e {public-private
|
|
|
|
|
key pair} that consists of a \e certificate and a corresponding
|
|
|
|
|
\e {private key} and is identified by an \e alias. The key pair is used to
|
|
|
|
|
verify that the future versions of your application are actually created by
|
|
|
|
|
you.
|
|
|
|
|
|
|
|
|
|
\warning Keep the key pair in a safe place and take back up copies, because
|
|
|
|
|
you cannot update the application if you lose the key pair.
|
|
|
|
|
|
|
|
|
|
You can use \QC to generate a keystore and a \e {self-signed} certificate.
|
|
|
|
|
The generated certificate has the structure of an X.509 v3 digital
|
|
|
|
|
certificate. It contains information about the version, serial number, and
|
|
|
|
|
validity period of the certificate, the ID of the algorithm that is used to
|
|
|
|
|
encrypt the data, the organization that issued the certificate, and the
|
|
|
|
|
\e subject (owner) of the certificate. In case of a self-signed certificate,
|
|
|
|
|
the issuer and owner of the certificate are the same. In addition, the
|
|
|
|
|
certificate contains information about the algorithm that is used to sign
|
|
|
|
|
the certificate, as well as the signature of the certificate.
|
|
|
|
|
|
|
|
|
|
The keystore is protected by a password. In addition, you can protect each
|
|
|
|
|
alias with its individual password.
|
|
|
|
|
|
|
|
|
|
When you sign an Android application, you must select a keystore that
|
|
|
|
|
contains certificates and a certificate alias from the keystore. The public
|
|
|
|
|
key (certificate) for the alias is embedded into the APK during signing.
|
|
|
|
|
|
|
|
|
|
To create a keystore and a self-signed certificate:
|
|
|
|
|
|
|
|
|
|
\list 1
|
|
|
|
|
|
2014-12-11 15:43:19 +01:00
|
|
|
\li In the \uicontrol Keystore field, select \uicontrol Create to create a new
|
|
|
|
|
keystore that contains one key pair in the \uicontrol {Create Keystore and
|
2014-11-18 11:36:38 +01:00
|
|
|
a Certificate} dialog:
|
|
|
|
|
|
|
|
|
|
\image qtcreator-android-certificate.png
|
|
|
|
|
|
2014-12-11 15:43:19 +01:00
|
|
|
\li In the \uicontrol Keystore group, enter a password to protect the
|
2014-11-18 11:36:38 +01:00
|
|
|
keystore.
|
|
|
|
|
|
2014-12-11 15:43:19 +01:00
|
|
|
\li In the \uicontrol Certificate group, specify the key size and validity
|
2014-11-18 11:36:38 +01:00
|
|
|
period of the certificate. You can specify a separate password to
|
|
|
|
|
protect the key pair or use the keystore password.
|
|
|
|
|
|
2014-12-11 15:43:19 +01:00
|
|
|
\li In the \uicontrol {Certificate Distinguished Names} group, enter
|
2014-11-18 11:36:38 +01:00
|
|
|
information about yourself and your company or organization that
|
|
|
|
|
identifies the issuer and the owner of the key pair.
|
|
|
|
|
|
2014-12-11 15:43:19 +01:00
|
|
|
\li Select \uicontrol Save.
|
2014-11-18 11:36:38 +01:00
|
|
|
|
2014-12-11 15:43:19 +01:00
|
|
|
\li In the \uicontrol {Keystore File Name} dialog, enter a name for the
|
2014-11-18 11:36:38 +01:00
|
|
|
keystore and select a location for it.
|
|
|
|
|
|
2014-12-11 15:43:19 +01:00
|
|
|
\li In the \uicontrol Keystore dialog, enter the keystore password to create
|
2014-11-18 11:36:38 +01:00
|
|
|
the key pair in the keystore.
|
|
|
|
|
|
|
|
|
|
\endlist
|
|
|
|
|
|
|
|
|
|
To sign an Android package by using a key pair, specify settings in the
|
2014-12-11 15:43:19 +01:00
|
|
|
\uicontrol {Sign package} group:
|
2014-11-18 11:36:38 +01:00
|
|
|
|
|
|
|
|
\list 1
|
|
|
|
|
|
2014-12-11 15:43:19 +01:00
|
|
|
\li In the \uicontrol Keystore field, select \uicontrol Choose to select an existing
|
2014-11-18 11:36:38 +01:00
|
|
|
keystore.
|
|
|
|
|
|
2014-12-11 15:43:19 +01:00
|
|
|
\li In the \uicontrol {Certificate alias} field, select an alias from the list
|
2014-11-18 11:36:38 +01:00
|
|
|
of key pairs that the keystore contains.
|
|
|
|
|
|
2014-12-11 15:43:19 +01:00
|
|
|
\li Select the \uicontrol {Sign package} check box to use the alias to
|
2014-11-18 11:36:38 +01:00
|
|
|
sign the Android package.
|
|
|
|
|
|
|
|
|
|
\endlist
|
2013-10-31 14:35:05 +01:00
|
|
|
|
2014-09-22 16:45:14 +02:00
|
|
|
\section3 Adding External Libraries
|
2013-10-31 14:35:05 +01:00
|
|
|
|
|
|
|
|
\QC automatically detects which Qt libraries the application uses and adds
|
|
|
|
|
them as dependencies. If the application needs external libraries, specify
|
2014-12-11 15:43:19 +01:00
|
|
|
them in the \uicontrol {Additional Libraries} field. The libraries are copied into
|
2013-10-31 14:35:05 +01:00
|
|
|
your application's library folder and loaded on startup.
|
|
|
|
|
|
|
|
|
|
For example, to enable OpenSSL in your application, add the paths to the
|
|
|
|
|
required \c libssl.so and \c libcrypto.so libraries to the
|
2014-12-11 15:43:19 +01:00
|
|
|
\uicontrol {Additional Libraries} field.
|
2013-10-31 14:35:05 +01:00
|
|
|
|
2014-09-22 16:45:14 +02:00
|
|
|
\section3 Editing Manifest Files
|
2013-10-31 14:35:05 +01:00
|
|
|
|
2014-04-16 17:05:35 +02:00
|
|
|
You can use the qmake variables to specify all
|
2013-10-31 14:35:05 +01:00
|
|
|
the settings you need for the \c androiddeployqt tool and you do not need an
|
|
|
|
|
Android manifest file until you want to publish the package in an
|
|
|
|
|
application store. To specify additional settings for APK packages, you can
|
|
|
|
|
create an Android manifest file and edit it in \QC. Select
|
2014-12-11 15:43:19 +01:00
|
|
|
\uicontrol {Create Templates} to create the file and to open it in the
|
2013-10-31 14:35:05 +01:00
|
|
|
Android Manifest Editor.
|
|
|
|
|
|
|
|
|
|
\image qtcreator-android-manifest-editor.png "Android Manifest Editor"
|
|
|
|
|
|
2014-09-22 16:45:14 +02:00
|
|
|
\list 1
|
2013-10-31 14:35:05 +01:00
|
|
|
|
2014-12-11 15:43:19 +01:00
|
|
|
\li In the \uicontrol {Package name} field, enter a package name for the application.
|
2013-10-31 14:35:05 +01:00
|
|
|
The application is launched by an automatically generated Java launcher that
|
|
|
|
|
is packaged with the application into an Android package (.apk). For more
|
|
|
|
|
information, see
|
|
|
|
|
\l{http://developer.android.com/guide/components/fundamentals.html}
|
|
|
|
|
{Android Application Fundamentals}.
|
|
|
|
|
|
2014-09-22 16:45:14 +02:00
|
|
|
\li You can specify an internal version number for the package in the
|
2014-12-11 15:43:19 +01:00
|
|
|
\uicontrol {Version code} field. It is used to determine whether one version of
|
|
|
|
|
the application is more recent than another. In the \uicontrol {Version name}
|
2013-10-31 14:35:05 +01:00
|
|
|
field, specify the version number that is shown to users.
|
|
|
|
|
|
2014-12-11 15:43:19 +01:00
|
|
|
\li In the \uicontrol {Minimum required SDK} field, select the minimum API level
|
2014-04-16 17:05:35 +02:00
|
|
|
required to run the application. The minimum supported API level is
|
|
|
|
|
android-9. \QC does not allow you to select an API
|
2013-10-31 14:35:05 +01:00
|
|
|
level that the Qt version specified for the kit does not support.
|
|
|
|
|
|
2014-12-11 15:43:19 +01:00
|
|
|
\li In the \uicontrol {Target SDK} field, select the targeted API level of the
|
2013-10-31 14:35:05 +01:00
|
|
|
application. This affects the activation of some compatibility features in
|
|
|
|
|
the OS. The value used by the \c androiddeployqt tool by default is 14, which
|
|
|
|
|
means that the overflow button in the system navigation bar will not be
|
|
|
|
|
enabled by default.
|
|
|
|
|
|
2014-12-11 15:43:19 +01:00
|
|
|
\li In the \uicontrol Application group, you can give the application a name and
|
2013-10-31 14:35:05 +01:00
|
|
|
select an icon for it. The three icon fields can contain different versions
|
|
|
|
|
of the icon with low, medium, and high DPI values, from left to right.
|
2015-07-28 17:10:50 +02:00
|
|
|
You can also give an activity a name and select the activity to run.
|
2013-10-31 14:35:05 +01:00
|
|
|
|
2014-12-11 15:43:19 +01:00
|
|
|
\li In the \uicontrol Permissions field, you can specify the permissions that your
|
2013-10-31 14:35:05 +01:00
|
|
|
application needs. Users are asked to grant the permissions when they
|
|
|
|
|
install the application. Android OS then grants the application access to
|
|
|
|
|
the appropriate data and features.
|
|
|
|
|
|
2014-12-11 15:43:19 +01:00
|
|
|
\li Select the \uicontrol {Include default permissions for Qt modules} and
|
|
|
|
|
\uicontrol {Include default features for Qt modules} check boxes to add the
|
2014-09-22 16:45:14 +02:00
|
|
|
permissions needed by Qt libraries.
|
|
|
|
|
|
2014-12-11 15:43:19 +01:00
|
|
|
\li To add permissions, select them in the list, and then select \uicontrol Add.
|
2014-09-22 16:45:14 +02:00
|
|
|
|
|
|
|
|
\endlist
|
|
|
|
|
|
2014-12-11 15:43:19 +01:00
|
|
|
Select the \uicontrol {XML Source} tab to edit the file in XML format.
|
2014-09-22 16:45:14 +02:00
|
|
|
|
|
|
|
|
\section1 Installing Ministro
|
|
|
|
|
|
|
|
|
|
The easiest way to install Ministro is to do it on the device via Google
|
|
|
|
|
Play. When you run the application for the first time, a dialog pops up and
|
|
|
|
|
guides you through the installation.
|
|
|
|
|
|
|
|
|
|
To use \QC to install Ministro, you must first download the Ministro .apk
|
|
|
|
|
from the Google Market or from the
|
|
|
|
|
\l{http://necessitas.kde.org/necessitas/ministro.php}{Ministro} home page.
|
|
|
|
|
|
2014-12-11 15:43:19 +01:00
|
|
|
Then select \uicontrol Projects > \uicontrol Run > \uicontrol {Install Ministro from APK}.
|
2014-09-22 16:45:14 +02:00
|
|
|
|
|
|
|
|
You can use this option also to install any Android package (.apk).
|
|
|
|
|
|
|
|
|
|
You can use this option to install applications on an Android Virtual
|
|
|
|
|
Device (AVD).
|
2014-07-29 14:58:39 +02:00
|
|
|
|
2012-07-24 15:31:23 +02:00
|
|
|
*/
|
|
|
|
|
|