2012-10-02 09:12:39 +02:00
|
|
|
/**************************************************************************
|
2012-07-24 15:31:23 +02:00
|
|
|
**
|
2014-01-07 13:27:11 +01:00
|
|
|
** Copyright (c) 2014 Digia Plc and/or its subsidiary(-ies).
|
2012-10-02 09:12:39 +02:00
|
|
|
** Contact: http://www.qt-project.org/legal
|
2012-07-24 15:31:23 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator
|
2012-07-24 15:31:23 +02:00
|
|
|
**
|
|
|
|
**
|
|
|
|
** GNU Free Documentation License
|
|
|
|
**
|
|
|
|
** 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.
|
|
|
|
**
|
|
|
|
**
|
2012-10-02 09:12:39 +02: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-connecting-mobile.html
|
2012-07-24 15:31:23 +02:00
|
|
|
\page creator-developing-android.html
|
2013-10-07 10:29:39 +02:00
|
|
|
\nextpage creator-developing-baremetal.html
|
2012-07-24 15:31:23 +02:00
|
|
|
|
|
|
|
\title Connecting Android Devices
|
|
|
|
|
|
|
|
You can connect Android devices to the development PC to build, run, debug,
|
|
|
|
and analyze applications on them from \QC.
|
|
|
|
|
|
|
|
If you have a tool chain for building applications for Android devices
|
2012-09-03 17:50:37 +02:00
|
|
|
installed on the development PC, you can add it to \QC. You can then add a
|
|
|
|
\l{glossary-buildandrun-kit}{kit}
|
|
|
|
with the Android device type, the tool chain, and the Qt version for Android,
|
2013-03-04 13:21:27 +01:00
|
|
|
to build and run applications on Android devices. You can also allow \QC to
|
|
|
|
automatically configure the kit.
|
2012-07-24 15:31:23 +02: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
|
|
|
|
the applications on them, and to read logs from them. It includes a client
|
|
|
|
and server that run on the development host and a daemon that runs on the
|
|
|
|
emulator or device.
|
|
|
|
|
2012-07-24 15:31:23 +02:00
|
|
|
\section1 Requirements
|
|
|
|
|
|
|
|
To use \QC to develop Qt applications for Android, you need the following:
|
|
|
|
|
|
|
|
\list
|
|
|
|
|
2013-11-15 15:54:25 +01:00
|
|
|
\li \l{http://www.oracle.com/technetwork/java/javase/downloads/index.html}
|
|
|
|
{Java SE Development Kit (JDK)} version 6, or later
|
2013-10-31 14:35:05 +01:00
|
|
|
|
2014-09-22 12:34:28 +02:00
|
|
|
\li A build tool for building application packages for Android devices:
|
|
|
|
|
|
|
|
\list
|
|
|
|
|
|
|
|
\li \l{http://ant.apache.org/bindownload.cgi}{Apache Ant} 1.8.0,
|
|
|
|
or later
|
|
|
|
|
|
|
|
\li \l{http://www.gradle.org}{Gradle}
|
|
|
|
|
|
|
|
\endlist
|
2012-07-24 15:31:23 +02:00
|
|
|
|
2014-04-16 17:05:35 +02:00
|
|
|
\li A tool chain for building applications for Android devices provided
|
|
|
|
by the
|
2013-03-04 13:21:27 +01:00
|
|
|
\l{http://developer.android.com/sdk/index.html}{Android SDK} and
|
|
|
|
\l{http://developer.android.com/tools/sdk/ndk/index.html}
|
2014-04-16 17:05:35 +02:00
|
|
|
{Android NDK} from Google.
|
2012-07-24 15:31:23 +02:00
|
|
|
|
2013-11-15 15:54:25 +01:00
|
|
|
\li On Windows, you also need the following:
|
|
|
|
|
|
|
|
\list
|
|
|
|
|
|
|
|
\li MinGW v4.8.0 revision 2
|
|
|
|
|
|
|
|
\li Android Debug Bridge (ADB) driver on the Windows platform to
|
|
|
|
enable USB debugging. The default USB driver on Windows does not
|
|
|
|
allow debugging. For more information about obtaining the USB
|
|
|
|
driver, see \l{http://developer.android.com/sdk/win-usb.html}.
|
|
|
|
|
|
|
|
After installing the driver, try running a few basic
|
|
|
|
\l{http://developer.android.com/tools/help/adb.html}{adb}
|
|
|
|
commands to check that your device responds to them.
|
|
|
|
|
|
|
|
\endlist
|
|
|
|
|
|
|
|
\endlist
|
|
|
|
|
|
|
|
After installing these tools, update the Android SDK to get the API
|
|
|
|
and tools packages required for development. You can use the
|
|
|
|
\l{http://developer.android.com/tools/help/android.html}{android} tool
|
|
|
|
that comes with the SDK Tools package. For example, on Ubuntu the
|
|
|
|
following command starts the
|
|
|
|
\l{http://developer.android.com/sdk/installing/adding-packages.html}
|
|
|
|
{Android SDK Manager}, where you can select the packages to install:
|
|
|
|
|
|
|
|
\code
|
|
|
|
./android update sdk
|
|
|
|
\endcode
|
2012-07-24 15:31:23 +02:00
|
|
|
|
2014-09-22 12:34:28 +02:00
|
|
|
\section1 Selecting the APK Build Tool
|
|
|
|
|
|
|
|
On Android, applications are distributed in specially structured type of ZIP
|
|
|
|
packages called APK. You can use either Ant or Gradle to build APKs. Using
|
|
|
|
Gradle has the following benefits:
|
|
|
|
|
|
|
|
\list
|
|
|
|
|
|
|
|
\li It is 25 to 50 percent faster than Ant when rebuilding packages.
|
|
|
|
|
|
|
|
\li It is integrated with Android Studio.
|
|
|
|
|
|
|
|
\li It supports easily adding Android Extras libraries, such as
|
|
|
|
Google Play services or Android extension files (.obb) to your
|
|
|
|
project.
|
|
|
|
|
|
|
|
\endlist
|
|
|
|
|
2014-04-16 17:05:35 +02:00
|
|
|
\section1 Setting Up the Development Environment
|
2012-07-24 15:31:23 +02:00
|
|
|
|
2014-01-17 10:19:58 +01:00
|
|
|
You must download and install the latest Android NDK and SDK, and update the
|
|
|
|
SDK to get the API and tools packages needed for development. In addition,
|
|
|
|
you must install Qt for Android as part of Qt 5.2, or later.
|
|
|
|
|
|
|
|
For more information, see \l{Qt for Android}.
|
2012-07-24 15:31:23 +02:00
|
|
|
|
|
|
|
To configure connections between \QC and Android devices:
|
|
|
|
|
|
|
|
\list 1
|
|
|
|
|
2014-12-11 15:43:19 +01:00
|
|
|
\li Select \uicontrol Tools > \uicontrol Options > \uicontrol Android to add paths to the
|
2014-01-17 10:19:58 +01:00
|
|
|
Android NDK and SDK.
|
2012-07-24 15:31:23 +02:00
|
|
|
|
2014-03-25 15:39:43 +01:00
|
|
|
You can use the
|
|
|
|
\inlineimage qtcreator-options-android-download-button.png
|
2014-12-11 15:43:19 +01:00
|
|
|
(\uicontrol Download) buttons to go to the sites where you can download
|
2014-03-25 15:39:43 +01:00
|
|
|
the Android NDK and SDK.
|
|
|
|
|
2014-01-17 10:19:58 +01:00
|
|
|
\image qtcreator-options-android1.png "Android options"
|
2012-07-24 15:31:23 +02:00
|
|
|
|
2014-12-11 15:43:19 +01:00
|
|
|
\li Select the \uicontrol {Automatically create kits for Android tool chains}
|
2013-03-04 13:21:27 +01:00
|
|
|
check box to allow \QC to create the kits for you. \QC displays a
|
|
|
|
warning if it cannot find a suitable Qt version.
|
2012-07-24 15:31:23 +02:00
|
|
|
|
2014-09-22 12:34:28 +02:00
|
|
|
\li Select the tool to use for building application packages:
|
|
|
|
|
|
|
|
\list
|
|
|
|
|
2014-12-11 15:43:19 +01:00
|
|
|
\li To use Gradle, select the \uicontrol {Use Gradle instead of Ant}
|
2014-09-22 12:34:28 +02:00
|
|
|
check box.
|
|
|
|
|
|
|
|
\li To use Ant, add the path to the Ant executable in the
|
2014-12-11 15:43:19 +01:00
|
|
|
\uicontrol {Ant executable} field.
|
2014-09-22 12:34:28 +02:00
|
|
|
|
|
|
|
\endlist
|
|
|
|
|
2014-12-11 15:43:19 +01:00
|
|
|
\li Select \uicontrol File > \uicontrol {New File or Project} > \uicontrol Application >
|
|
|
|
\uicontrol {Qt Quick Application} > \uicontrol Choose, and
|
2013-05-03 16:57:37 +02:00
|
|
|
follow the instructions of the wizard. For more information, see
|
|
|
|
\l{Creating Qt Quick Projects}.
|
2012-07-24 15:31:23 +02:00
|
|
|
|
2013-02-06 08:50:23 +01:00
|
|
|
\li To specify settings for deploying applications to Android, select
|
2014-12-11 15:43:19 +01:00
|
|
|
\uicontrol Projects > \uicontrol Run for the \uicontrol Android kit, and then select
|
|
|
|
\uicontrol Details to view the \uicontrol {Deploy configurations}. For more
|
2012-07-24 15:31:23 +02:00
|
|
|
information about the options you have, see
|
|
|
|
\l{Deploying Applications to Android Devices}.
|
|
|
|
|
2014-01-17 10:19:58 +01:00
|
|
|
\li Enable debugging on your Android device.
|
2012-07-24 15:31:23 +02:00
|
|
|
|
2014-01-17 10:19:58 +01:00
|
|
|
Debugging is enabled in different ways on different Android devices.
|
2014-12-11 15:43:19 +01:00
|
|
|
Look for \uicontrol {USB Debugging} under \uicontrol {Developer Options}. On
|
|
|
|
some devices \uicontrol {Developer Options} is hidden and becomes visible
|
|
|
|
when you tap the \uicontrol {Build number} field in \uicontrol Settings >
|
|
|
|
\uicontrol About several times.
|
2013-05-03 16:57:37 +02:00
|
|
|
|
2014-01-17 10:19:58 +01:00
|
|
|
\li Connect the Android device to the development PC with a USB cable.
|
|
|
|
You might be asked to select a device in the
|
2014-12-11 15:43:19 +01:00
|
|
|
\uicontrol {Select Android Devices} dialog.
|
2014-01-17 10:19:58 +01:00
|
|
|
\endlist
|
2013-05-03 16:57:37 +02:00
|
|
|
|
2013-10-31 14:35:05 +01:00
|
|
|
\section1 Selecting Android Devices
|
|
|
|
|
|
|
|
When you deploy an application to an Android device with Android
|
2014-12-11 15:43:19 +01:00
|
|
|
version 4.2 or later, the \uicontrol {Select Android Devices} dialog opens. It
|
2013-10-31 14:35:05 +01:00
|
|
|
lists the devices that are connected to the development PC. and their
|
2014-12-11 15:43:19 +01:00
|
|
|
status. You can select devices from the \uicontrol {Compatible Devices} list for
|
2013-10-31 14:35:05 +01:00
|
|
|
deployment.
|
|
|
|
|
|
|
|
If \QC determines that a device is not ready for deployment, it places the
|
2014-12-11 15:43:19 +01:00
|
|
|
device in the \uicontrol {Incompatible Devices} list, with information about the
|
2013-10-31 14:35:05 +01:00
|
|
|
issue. For example, you might need to authorize the connection on the
|
|
|
|
device. After you authorize the connection on the device, select
|
2014-12-11 15:43:19 +01:00
|
|
|
\uicontrol {Refresh Device List}. The device is moved to the
|
|
|
|
\uicontrol {Compatible Devices} list and you can select it for deployment.
|
2013-10-31 14:35:05 +01:00
|
|
|
|
2014-12-11 15:43:19 +01:00
|
|
|
Other reasons for placing a device on the \uicontrol {Incompatible Devices} are
|
2013-10-31 14:35:05 +01:00
|
|
|
that the Android version on the device is too old or that the tool chain
|
|
|
|
used for building does not match the Android architecture on the device
|
|
|
|
(for example, you cannot deploy an ARM build on an x86 device).
|
|
|
|
|
|
|
|
\image qtcreator-android-select-devices.png "Select Android Devices dialog"
|
|
|
|
|
|
|
|
Android Virtual Devices (AVD) are also listed. To create new AVDs, select
|
2014-12-11 15:43:19 +01:00
|
|
|
\uicontrol {Create Android Virtual Device}.
|
2013-10-31 14:35:05 +01:00
|
|
|
|
|
|
|
To set a device as the default device for a particular Android architecture,
|
2014-12-11 15:43:19 +01:00
|
|
|
select the \uicontrol {Always use this device for architecture} check box. The
|
|
|
|
\uicontrol {Select Android Devices} dialog will not appear until you switch to
|
2013-10-31 14:35:05 +01:00
|
|
|
another project or restart \QC.
|
|
|
|
|
2013-05-03 16:57:37 +02:00
|
|
|
\section1 Using the Android Emulator
|
|
|
|
|
|
|
|
To run your application on the Android Emulator, you must create Android
|
2014-12-11 15:43:19 +01:00
|
|
|
virtual devices (AVD). Select \uicontrol Tools > \uicontrol Options > \uicontrol Android >
|
|
|
|
\uicontrol Add. If you run an application without a device connected to the
|
2013-05-03 16:57:37 +02:00
|
|
|
development PC and without an AVD specified, \QC asks you to add an AVD.
|
|
|
|
|
2014-12-11 15:43:19 +01:00
|
|
|
To manage AVDs, select \uicontrol {Start AVD Manager}.
|
2013-05-03 16:57:37 +02:00
|
|
|
|
|
|
|
\note The Android Emulator has a bug that prevents it from starting on some
|
|
|
|
systems. If the Android Emulator does not start, you can try starting it
|
|
|
|
manually by running the \c {emulator-arm} command from the command line.
|
|
|
|
|
2012-07-24 15:31:23 +02:00
|
|
|
\section1 Debugging on Android Devices
|
|
|
|
|
|
|
|
Android devices support debugging multi-thread applications in version
|
|
|
|
2.2.1 and later. If you use AVD, select Android 2.3, or later. For more
|
|
|
|
information, see the Android documentation.
|
|
|
|
|
|
|
|
In addition, debugging is supported at android-10 API level, or higher. In
|
2014-12-11 15:43:19 +01:00
|
|
|
the run settings for the project, in the \uicontrol {Android build SDK} field,
|
2012-07-24 15:31:23 +02:00
|
|
|
select android-10, or higher. 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?}.
|
|
|
|
|
|
|
|
\note Select a \l{glossary-build-config}{debug build configuration} to build
|
|
|
|
the application for debugging.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|