2016-01-15 14:51:16 +01:00
|
|
|
/****************************************************************************
|
2012-07-24 15:31:23 +02:00
|
|
|
**
|
2022-02-07 17:27:36 +01:00
|
|
|
** Copyright (C) 2022 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
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
\page creator-developing-android.html
|
2018-08-10 16:15:05 +02:00
|
|
|
\previouspage creator-connecting-mobile.html
|
|
|
|
|
\if defined(qtdesignstudio)
|
|
|
|
|
\nextpage creator-developing-generic-linux.html
|
|
|
|
|
\else
|
2013-10-07 10:29:39 +02:00
|
|
|
\nextpage creator-developing-baremetal.html
|
2018-08-10 16:15:05 +02:00
|
|
|
\endif
|
2012-07-24 15:31:23 +02:00
|
|
|
|
|
|
|
|
\title Connecting Android Devices
|
|
|
|
|
|
2020-08-06 09:58:46 +02:00
|
|
|
You can connect Android devices to the development PC using USB cables
|
|
|
|
|
to build, run, debug, and analyze applications from \QC. Devices with
|
2021-10-29 18:29:58 +02:00
|
|
|
Android version 4.1 (API level 16) or later are supported when developing
|
|
|
|
|
with Qt 5 and devices with Android version 6.0 (API level 23) when
|
|
|
|
|
developing with Qt 6.
|
2012-07-24 15:31:23 +02:00
|
|
|
|
2020-08-06 09:58:46 +02:00
|
|
|
To develop for Android, you must have a tool chain for building applications
|
|
|
|
|
for Android devices installed on the development PC. \QC can automatically
|
|
|
|
|
dowload and install the tool chain and create a suitable build and run
|
|
|
|
|
\l{glossary-buildandrun-kit}{kit} that contains the tool chain and the Qt
|
|
|
|
|
version for Android for the device's architecture.
|
|
|
|
|
|
|
|
|
|
Starting from Qt 5.14.0, the Qt for Android package contains all the
|
|
|
|
|
architectures (ABIs) installed as one.
|
|
|
|
|
|
2021-03-25 13:32:57 +01:00
|
|
|
To enable helpful code editing features for Java, such as code completion,
|
2022-06-09 17:07:23 +02:00
|
|
|
highlighting, function tooltips, and navigating in code, add a
|
|
|
|
|
\l{Java Language Server}{Java language server}.
|
2021-03-25 13:32:57 +01:00
|
|
|
|
2013-02-15 15:10:45 +01:00
|
|
|
The Android Debug Bridge (adb) command line tool is integrated to \QC to
|
|
|
|
|
enable you to deploy applications to connected Android devices, to run
|
2020-03-12 16:45:39 +02:00
|
|
|
them, and to read their logs. It includes a client and server that run on
|
|
|
|
|
the development host and a daemon that runs on the emulator or device.
|
2013-02-15 15:10:45 +01:00
|
|
|
|
2012-07-24 15:31:23 +02:00
|
|
|
\section1 Requirements
|
|
|
|
|
|
2020-08-06 09:58:46 +02:00
|
|
|
To use \QC to develop Qt applications for Android, you need
|
|
|
|
|
\l{Qt for Android} 5.2, or later, and the tool chain that \QC
|
|
|
|
|
can automatically download, install, and configure for you.
|
2022-02-18 16:48:33 +01:00
|
|
|
For more information, see \l{Manually Installing the Prerequisites}.
|
2013-11-15 15:54:25 +01:00
|
|
|
|
2020-08-06 09:58:46 +02:00
|
|
|
\section1 Specifying Android Device Settings
|
2013-11-15 15:54:25 +01:00
|
|
|
|
2020-08-06 09:58:46 +02:00
|
|
|
\QC offers to automatically install all the necessary packages and tools and
|
|
|
|
|
to set up your development environment by creating debuggers, tool chains,
|
|
|
|
|
and kits. You can use \QC to:
|
2017-09-04 13:50:33 +02:00
|
|
|
|
|
|
|
|
\list
|
2020-08-06 09:58:46 +02:00
|
|
|
\li Download and extract the Android SDK Command-line Tools.
|
|
|
|
|
\li Install or update the essential packages such as NDKs,
|
|
|
|
|
build tools, and platform tools.
|
|
|
|
|
\endlist
|
2020-03-12 16:45:39 +02:00
|
|
|
|
2020-08-06 09:58:46 +02:00
|
|
|
To set up the development environment for Android:
|
2020-03-12 16:45:39 +02:00
|
|
|
|
2020-08-06 09:58:46 +02:00
|
|
|
\list 1
|
2022-06-27 12:12:54 +02:00
|
|
|
\li Select \uicontrol Edit > \uicontrol Preferences > \uicontrol Devices >
|
2021-10-29 18:29:58 +02:00
|
|
|
\uicontrol Android on Windows and Linux or \uicontrol {\QC} >
|
|
|
|
|
\uicontrol Preferences > \uicontrol Devices > \uicontrol Android on
|
|
|
|
|
\macos.
|
2020-08-06 09:58:46 +02:00
|
|
|
\image qtcreator-options-android-main.png "Android options"
|
|
|
|
|
\li In the \uicontrol {JDK location} field, set the path to the JDK.
|
|
|
|
|
\QC checks the JDK installation and reports errors.
|
|
|
|
|
|
|
|
|
|
By default, \QC tries to find a supported \l{AdoptOpenJDK} or
|
|
|
|
|
\l{OpenJDK} installation. If none is found, you must set the path
|
|
|
|
|
manually. If you don't have a supported JDK installed, select
|
2021-12-09 11:21:39 +01:00
|
|
|
\inlineimage icons/online.png
|
2020-08-06 09:58:46 +02:00
|
|
|
to open the JDK download web page in the default browser.
|
|
|
|
|
|
|
|
|
|
\note We recommended using a 64-bit JDK, because the 32-bit one
|
|
|
|
|
might cause issues with \c cmdline-tools, and some packages might
|
|
|
|
|
not be listed.
|
|
|
|
|
\li In the \uicontrol {Android SDK location} field, set the path to the
|
|
|
|
|
folder where you want the \l{Android SDK Command-line Tools} to be
|
|
|
|
|
installed.
|
|
|
|
|
\li Select \uicontrol {Set Up SDK} to automatically download and extract
|
|
|
|
|
the Android SDK Command-line Tools to the selected path.
|
|
|
|
|
|
|
|
|
|
The SDK Manager checks whether the tool chain is installed.
|
|
|
|
|
If packages are missing or updates are needed, the SDK Manager
|
|
|
|
|
offers to add or remove those packages. Before taking action, it
|
|
|
|
|
prompts you to accept the changes it is about to make. In addition,
|
|
|
|
|
it prompts you to accept Google licenses, as necessary.
|
2021-10-29 18:29:58 +02:00
|
|
|
\li The installed NDK versions are listed in
|
|
|
|
|
\uicontrol {Android NDK list}.
|
2020-08-06 09:58:46 +02:00
|
|
|
The locked items were installed by the SDK Manager,
|
|
|
|
|
and can only be modified from the \uicontrol {SDK Manager} tab.
|
|
|
|
|
For more information, see \l{Managing Android NDK Packages}.
|
2022-02-07 17:27:36 +01:00
|
|
|
\li Select the \uicontrol {Automatically create kits for Android tool chains}
|
|
|
|
|
check box to allow \QC to create the kits for you. \QC displays a
|
|
|
|
|
warning if it cannot find a suitable Qt version.
|
|
|
|
|
\li Optionally, in the \uicontrol {Android OpenSSL Settings} group, set
|
|
|
|
|
the path to the prebuilt OpenSSL libraries.
|
2017-09-04 13:50:33 +02:00
|
|
|
|
2020-08-06 09:58:46 +02:00
|
|
|
For Qt applications that require OpenSSL support, \QC allows to
|
|
|
|
|
quickly add the \l {Android OpenSSL support} to your project.
|
|
|
|
|
For more information, see \l{Adding External Libraries}.
|
2021-10-29 18:29:58 +02:00
|
|
|
\li Select \uicontrol {Download OpenSSL} to download the OpenSSL
|
|
|
|
|
repository to the selected path. If the automatic download fails,
|
|
|
|
|
the download web page opens for manual download.
|
2020-08-06 09:58:46 +02:00
|
|
|
\endlist
|
2017-09-04 13:50:33 +02:00
|
|
|
|
2020-08-06 09:58:46 +02:00
|
|
|
\section2 Manual Setup
|
2020-03-12 16:45:39 +02:00
|
|
|
|
2020-08-06 09:58:46 +02:00
|
|
|
\note We recommend that you use the latest Android SDK Command-Line Tools.
|
|
|
|
|
Using Android SDK Tools version 25.2.5 or earlier is not supported, because
|
|
|
|
|
they cannot be fully integrated with \QC.
|
2017-09-04 13:50:33 +02:00
|
|
|
|
2020-08-06 09:58:46 +02:00
|
|
|
However, if the automatic setup does not meet your needs, you can download
|
|
|
|
|
and install Android SDK Command-line Tools, and then install or update the
|
|
|
|
|
NDKs, tools and packages needed for development. For more information, see
|
|
|
|
|
\l{Getting Started with Qt for Android}.
|
2017-09-04 13:50:33 +02:00
|
|
|
|
2020-08-06 09:58:46 +02:00
|
|
|
\section2 Viewing Android Tool Chain Settings
|
2017-08-08 09:49:17 +02:00
|
|
|
|
2020-08-06 09:58:46 +02:00
|
|
|
The Android SDK Command-Line Tools download URL, the essential
|
|
|
|
|
packages list, and the appropriate NDK for each Qt version are defined in a JSON
|
|
|
|
|
configuration file. The file is located under the user's \QC
|
|
|
|
|
resource folder:
|
2017-10-17 12:58:22 +02:00
|
|
|
|
2020-08-06 09:58:46 +02:00
|
|
|
\badcode
|
|
|
|
|
# Linux and macOS
|
|
|
|
|
~/.config/QtProject/qtcreator/android/sdk_definitions.json
|
2012-07-24 15:31:23 +02:00
|
|
|
|
2020-08-06 09:58:46 +02:00
|
|
|
# Windows
|
|
|
|
|
C:\Users\Username\AppData\Local\QtProject\qtcreator\android\sdk_definitions.json
|
|
|
|
|
\endcode
|
2012-07-24 15:31:23 +02:00
|
|
|
|
2020-08-06 09:58:46 +02:00
|
|
|
For example, the SDK configuration file defines the NDK version 19.2.5345600
|
|
|
|
|
to be used for Qt 5.12.0 to 5.12.5 and Qt 5.13.0 to 5.13.1 versions:
|
2017-10-17 12:58:22 +02:00
|
|
|
|
2020-08-06 09:58:46 +02:00
|
|
|
\badcode
|
|
|
|
|
"specific_qt_versions": [
|
|
|
|
|
{
|
|
|
|
|
"versions": ["5.12.[0-5]", "5.13.[0-1]"],
|
|
|
|
|
"sdk_essential_packages": ["build-tools;28.0.2", "ndk;19.2.5345600"],
|
|
|
|
|
"ndk_path": "ndk/19.2.5345600"
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
\endcode
|
2017-10-17 12:58:22 +02:00
|
|
|
|
2020-08-06 09:58:46 +02:00
|
|
|
You can view the latest version of the configuration file that is up-to-date
|
|
|
|
|
with the Android SDK and NDK changes, \l{sdk_definitions.json}, in Git.
|
2017-10-17 12:58:22 +02:00
|
|
|
|
2020-08-06 09:58:46 +02:00
|
|
|
\section2 Managing Android NDK Packages
|
2017-10-17 12:58:22 +02:00
|
|
|
|
2022-06-27 12:12:54 +02:00
|
|
|
To view the installed \l{Android NDK} versions, select \uicontrol Edit >
|
|
|
|
|
\uicontrol Preferences > \uicontrol Devices > \uicontrol Android on Windows and
|
2021-10-29 18:29:58 +02:00
|
|
|
Linux or \uicontrol {\QC} > \uicontrol Preferences > \uicontrol Devices >
|
|
|
|
|
\uicontrol Android on \macos.
|
2020-03-12 16:45:39 +02:00
|
|
|
|
2020-08-06 09:58:46 +02:00
|
|
|
\image qtcreator-options-android-sdk-tools.png "Android NDK and SDK checks"
|
2020-03-12 16:45:39 +02:00
|
|
|
|
2020-08-06 09:58:46 +02:00
|
|
|
The locked versions were installed by the SDK Manager, and can only
|
|
|
|
|
be modified from the SDK Manager tab. For more information, see
|
|
|
|
|
\l{Managing Android SDK Packages}.
|
2012-07-24 15:31:23 +02:00
|
|
|
|
2021-12-09 11:21:39 +01:00
|
|
|
To manually download NDKs, select \inlineimage icons/online.png
|
2020-08-06 09:58:46 +02:00
|
|
|
.
|
2012-07-24 15:31:23 +02:00
|
|
|
|
2022-02-07 17:27:36 +01:00
|
|
|
To use the selected NDK version for all Qt versions by default, select
|
|
|
|
|
\uicontrol {Make Default}.
|
|
|
|
|
|
2020-08-06 09:58:46 +02:00
|
|
|
To add custom NDK paths manually to the global list of NDKs, select
|
|
|
|
|
\uicontrol Add. This creates custom tool chains and debuggers associated
|
|
|
|
|
to that NDK. However, you have to manually create a kit that uses the
|
|
|
|
|
custom NDK. For more information, see \l{Adding Kits}.
|
2013-05-03 16:57:37 +02:00
|
|
|
|
2017-10-17 12:58:22 +02:00
|
|
|
\section2 Managing Android SDK Packages
|
|
|
|
|
|
|
|
|
|
Since Android SDK Tools version 25.3.0, only a command-line tool,
|
2020-08-06 09:58:46 +02:00
|
|
|
\l {sdkmanager}, is provided by Android for SDK package management.
|
|
|
|
|
To make SDK management easier, \QC provides an SDK Manager for
|
|
|
|
|
installing, updating, and removing SDK packages. You can still use
|
|
|
|
|
sdkmanager for advanced SDK management.
|
2017-10-17 12:58:22 +02:00
|
|
|
|
2022-06-27 12:12:54 +02:00
|
|
|
To view the installed Android SDK packages, select \uicontrol Edit >
|
|
|
|
|
\uicontrol Preferences > \uicontrol Devices > \uicontrol Android >
|
2021-10-29 18:29:58 +02:00
|
|
|
\uicontrol {SDK Manager} on Windows and Linux or \uicontrol {\QC} >
|
|
|
|
|
\uicontrol Preferences > \uicontrol Devices > \uicontrol Android >
|
|
|
|
|
\uicontrol {SDK Manager} on \macos.
|
2017-10-17 12:58:22 +02:00
|
|
|
|
|
|
|
|
\image qtcreator-android-sdk-manager.png "Android SDK Manager"
|
|
|
|
|
|
2022-02-07 17:27:36 +01:00
|
|
|
You can show packages for the release channel you select in
|
|
|
|
|
\uicontrol {Show Packages} > \uicontrol Channel. Common channel IDs include
|
|
|
|
|
\uicontrol Stable, \uicontrol Beta, \uicontrol Dev, and \uicontrol Canary.
|
|
|
|
|
To show and update also obsolete packages, select
|
|
|
|
|
\uicontrol {Include obsolete}. To filter packages, select
|
|
|
|
|
\uicontrol Available, \uicontrol Installed, or \uicontrol All.
|
2017-10-17 12:58:22 +02:00
|
|
|
|
|
|
|
|
To update the installed Android SDK packages, select
|
|
|
|
|
\uicontrol {Update Installed}. Select the packages to update, and then
|
|
|
|
|
select \uicontrol Apply.
|
|
|
|
|
|
|
|
|
|
To specify advanced sdkmanager settings, select
|
|
|
|
|
\uicontrol {Advanced Options} and enter arguments in the
|
|
|
|
|
\uicontrol {SDK Manager arguments} field. The available arguments are listed
|
|
|
|
|
and described in \uicontrol {Available arguments}.
|
|
|
|
|
|
2022-02-07 17:27:36 +01:00
|
|
|
\image qtcreator-android-sdk-manager-arguments.png "Android SDK Manager Arguments dialog"
|
|
|
|
|
|
2020-03-12 16:45:39 +02:00
|
|
|
\section1 Managing Android Virtual Devices (AVD)
|
|
|
|
|
|
2022-06-27 12:12:54 +02:00
|
|
|
The available AVDs are listed in \uicontrol Edit > \uicontrol Preferences
|
2021-10-29 18:29:58 +02:00
|
|
|
> \uicontrol Devices on Windows and Linux or \uicontrol {\QC} >
|
|
|
|
|
\uicontrol Preferences > \uicontrol Devices > on \macos. You can add more
|
|
|
|
|
AVDs.
|
2013-10-31 14:35:05 +01:00
|
|
|
|
2021-10-29 18:29:58 +02:00
|
|
|
\image qtcreator-android-avd-manager.png "Android device in Devices"
|
2013-10-31 14:35:05 +01:00
|
|
|
|
2021-10-29 18:29:58 +02:00
|
|
|
You can see the status of the selected device in \uicontrol {Current state}.
|
|
|
|
|
To update the status information, select \uicontrol Refresh.
|
2013-10-31 14:35:05 +01:00
|
|
|
|
2021-10-29 18:29:58 +02:00
|
|
|
To start an AVD, select \uicontrol {Start AVD}. Usually, you don't need to
|
|
|
|
|
start AVDs separately because they are automatically started when you
|
|
|
|
|
select them in the \l{Building for Multiple Platforms}{kit selector} to
|
|
|
|
|
\l{Deploying Applications to Android Devices}{deploy applications} to them.
|
2013-10-31 14:35:05 +01:00
|
|
|
|
2021-10-29 18:29:58 +02:00
|
|
|
To remove an AVD from the list and the kit selector, select
|
|
|
|
|
\uicontrol {Erase AVD}.
|
2013-10-31 14:35:05 +01:00
|
|
|
|
2021-10-29 18:29:58 +02:00
|
|
|
To specify options for starting an AVD, select \uicontrol {AVD Arguments}.
|
2013-10-31 14:35:05 +01:00
|
|
|
|
2021-10-29 18:29:58 +02:00
|
|
|
\image qtcreator-android-avd-arguments.png "Startup options for AVDs"
|
2013-10-31 14:35:05 +01:00
|
|
|
|
2021-10-29 18:29:58 +02:00
|
|
|
Specify the options in \uicontrol {Emulator command-line startup options}.
|
|
|
|
|
For available options, see \l{Start the emulator from the command line}.
|
2013-05-03 16:57:37 +02:00
|
|
|
|
|
|
|
|
\note The Android Emulator has a bug that prevents it from starting on some
|
2021-10-29 18:29:58 +02:00
|
|
|
systems. If an AVD does not start, you can try starting it manually by
|
|
|
|
|
running the following commands:
|
2020-03-12 16:45:39 +02:00
|
|
|
|
|
|
|
|
\badcode
|
|
|
|
|
cd <ANDROID_SDK>/emulator
|
|
|
|
|
./emulator -avd <AVD_NAME>
|
|
|
|
|
\endcode
|
|
|
|
|
|
2021-10-29 18:29:58 +02:00
|
|
|
\section2 Creating a New AVD
|
|
|
|
|
|
|
|
|
|
To create new virtual devices:
|
|
|
|
|
|
|
|
|
|
\list 1
|
2022-06-27 12:12:54 +02:00
|
|
|
\li Select \uicontrol Edit > \uicontrol Preferences > \uicontrol Devices >
|
2021-10-29 18:29:58 +02:00
|
|
|
\uicontrol Add > \uicontrol {Android Device} on Windows and Linux
|
|
|
|
|
or \uicontrol {\QC} > \uicontrol Preferences > \uicontrol Devices >
|
|
|
|
|
\uicontrol Add > \uicontrol {Android Device} on \macos to open the
|
|
|
|
|
\uicontrol {Create New AVD} dialog.
|
|
|
|
|
\image qtcreator-android-create-avd.png "Create New AVD dialog"
|
|
|
|
|
\li Set the name, definition, architecture, target API level, and
|
|
|
|
|
SD card size of the device.
|
|
|
|
|
\li Select \uicontrol OK to create the AVD.
|
|
|
|
|
\endlist
|
|
|
|
|
|
|
|
|
|
For more advanced options for creating a new AVD, use the command-line tool
|
|
|
|
|
\l{avdmanager} or the Android Studio's native AVD Manager UI.
|
2013-05-03 16:57:37 +02:00
|
|
|
|
2012-07-24 15:31:23 +02:00
|
|
|
\section1 Debugging on Android Devices
|
|
|
|
|
|
2020-08-06 09:58:46 +02:00
|
|
|
Debugging is enabled in different ways on different Android devices.
|
|
|
|
|
Look for \uicontrol {USB Debugging} under \uicontrol {Developer Options}. On
|
|
|
|
|
some devices \uicontrol {Developer Options} is hidden and becomes visible
|
|
|
|
|
only when you tap the \uicontrol {Build number} field in \uicontrol Settings
|
|
|
|
|
> \uicontrol About several times. For more information, see
|
|
|
|
|
\l {Configure on-device developer options}.
|
|
|
|
|
|
2018-10-11 11:49:26 +02:00
|
|
|
Select a \l{glossary-build-config}{debug build configuration} to build
|
2012-07-24 15:31:23 +02:00
|
|
|
the application for debugging.
|
|
|
|
|
|
2018-07-19 12:52:21 +02:00
|
|
|
\note \QC cannot debug applications on Android devices if Android Studio is
|
2022-03-04 18:24:58 +01:00
|
|
|
running. If the following message is displayed in \l {Application Output},
|
|
|
|
|
close Android Studio and try again:
|
2020-03-12 16:45:39 +02:00
|
|
|
|
|
|
|
|
\badcode
|
|
|
|
|
Ignoring second debugger -accepting and dropping.
|
|
|
|
|
\endcode
|
2018-07-19 12:52:21 +02:00
|
|
|
*/
|