2012-10-02 09:12:39 +02:00
|
|
|
/**************************************************************************
|
2012-07-24 15:31:23 +02:00
|
|
|
**
|
2013-01-28 17:12:19 +01:00
|
|
|
** Copyright (c) 2013 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
|
|
|
|
|
|
|
/*!
|
|
|
|
|
|
|
|
\contentspage index.html
|
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-02-21 14:55:22 +01:00
|
|
|
\nextpage creator-developing-bb10.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-02-06 08:50:23 +01:00
|
|
|
\li OpenJDK Java Development Kit
|
2012-07-24 15:31:23 +02:00
|
|
|
|
|
|
|
To check whether you have OpenJDK installed, enter the following
|
|
|
|
command:
|
|
|
|
|
|
|
|
\c {java -version}
|
|
|
|
|
|
|
|
To install OpenJDK, enter the following command:
|
|
|
|
|
|
|
|
\c {sudo apt-get install openjdk-6-jdk}
|
|
|
|
|
2013-02-06 08:50:23 +01:00
|
|
|
\li \l{http://ant.apache.org/bindownload.cgi}{Apache Ant} 1.8.0, or
|
2012-07-24 15:31:23 +02:00
|
|
|
later
|
|
|
|
|
|
|
|
To check the Ant version, enter the following command on the command
|
|
|
|
line:
|
|
|
|
|
|
|
|
\c {ant -version}
|
|
|
|
|
2013-03-04 13:21:27 +01:00
|
|
|
\li A tool chain for building applications for Android devices. You have
|
|
|
|
several options, such as the
|
|
|
|
\l{http://developer.android.com/sdk/index.html}{Android SDK} and
|
|
|
|
\l{http://developer.android.com/tools/sdk/ndk/index.html}
|
2013-05-03 16:57:37 +02:00
|
|
|
{Android NDK} from Google (supported for development with Qt 5) or the
|
2013-03-04 13:21:27 +01:00
|
|
|
\l{http://necessitas.kde.org/necessitas/necessitas_sdk_installer.php}
|
2013-05-03 16:57:37 +02:00
|
|
|
{Necessitas SDK} (supported for development with Qt 4).
|
2012-07-24 15:31:23 +02:00
|
|
|
|
|
|
|
\endlist
|
|
|
|
|
2013-05-03 16:57:37 +02:00
|
|
|
\section1 Developing with Qt 4
|
2012-07-24 15:31:23 +02:00
|
|
|
|
2013-05-03 16:57:37 +02:00
|
|
|
The Necessitas SDK automatically sets the paths to the required software
|
|
|
|
in \QC, but you need to add the Qt version. \QC can then create the
|
|
|
|
necessary kits for you.
|
2012-07-24 15:31:23 +02:00
|
|
|
|
|
|
|
To configure connections between \QC and Android devices:
|
|
|
|
|
|
|
|
\list 1
|
|
|
|
|
2013-02-06 08:50:23 +01:00
|
|
|
\li Select \gui Tools > \gui Options > \gui {Build & Run} >
|
2013-03-04 13:21:27 +01:00
|
|
|
\gui {Qt Versions} > \gui Add to add the path to \c qmake path in
|
|
|
|
the Qt for Android SDK.
|
2012-07-24 15:31:23 +02:00
|
|
|
|
2013-05-03 16:57:37 +02:00
|
|
|
\li Select \gui Tools > \gui Options > \gui Android to check the paths
|
|
|
|
to the required software.
|
2012-07-24 15:31:23 +02:00
|
|
|
|
|
|
|
\image qtcreator-options-android.png "Android options"
|
|
|
|
|
2013-03-04 13:21:27 +01:00
|
|
|
\li Select the \gui {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.
|
2012-07-24 15:31:23 +02:00
|
|
|
|
2013-05-03 16:57:37 +02:00
|
|
|
\li To create an application, select \gui File >
|
|
|
|
\gui {New File or Project} > \gui Applications >
|
|
|
|
\gui {Qt Quick Application 1 (Built-in Elements)} or
|
|
|
|
\gui {Qt Quick Application 2 (Built-in Elements)} > \gui Choose, and
|
|
|
|
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 information for the Android manifest file, select
|
2013-03-04 13:21:27 +01:00
|
|
|
\gui Projects > \gui Run for the \gui Android kit.
|
|
|
|
|
|
|
|
\li Select \gui Details to view the
|
2012-07-24 15:31:23 +02:00
|
|
|
\gui {Package configurations}. For more information about the
|
|
|
|
options you have, see
|
|
|
|
\l{Specifying Run Settings for Android Devices}.
|
|
|
|
|
2013-02-06 08:50:23 +01:00
|
|
|
\li To specify settings for deploying applications to Android, select
|
2012-07-24 15:31:23 +02:00
|
|
|
\gui Details to view the \gui {Deploy configurations}. For more
|
|
|
|
information about the options you have, see
|
|
|
|
\l{Deploying Applications to Android Devices}.
|
|
|
|
|
|
|
|
\endlist
|
|
|
|
|
2013-05-03 16:57:37 +02:00
|
|
|
\section1 Developing with Qt 5
|
|
|
|
|
|
|
|
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 from the Qt 5.1 packages.
|
|
|
|
|
|
|
|
For more information, see
|
|
|
|
\l{http://qt-project.org/doc/qt-5.0/qtdoc/android-support.html}{Android}.
|
|
|
|
|
|
|
|
To configure connections between \QC and Android devices:
|
|
|
|
|
|
|
|
\list 1
|
|
|
|
|
|
|
|
\li Select \gui Tools > \gui Options > \gui Android to add paths to the
|
|
|
|
Android NDK and SDK.
|
|
|
|
|
|
|
|
\image qtcreator-options-android1.png "Android options"
|
|
|
|
|
|
|
|
\li Select the \gui {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 Select \gui File > \gui {New File or Project} > \gui Applications >
|
|
|
|
\gui {Qt Quick Application 2 (Built-in Elements)} > \gui Choose, and
|
|
|
|
follow the instructions of the wizard. For more information, see
|
|
|
|
\l{Creating Qt Quick Projects}.
|
|
|
|
|
|
|
|
\li To specify information for the Android manifest file, select
|
|
|
|
\gui Projects > \gui Run for the \gui Android kit.
|
|
|
|
|
|
|
|
\li Select \gui Details to view the
|
|
|
|
\gui {Package configurations}. For more information about the
|
|
|
|
options you have, see
|
|
|
|
\l{Specifying Run Settings for Android Devices}.
|
|
|
|
|
|
|
|
\li To specify settings for deploying applications to Android, select
|
|
|
|
\gui Details to view the \gui {Deploy configurations}. For more
|
|
|
|
information about the options you have, see
|
|
|
|
\l{Deploying Applications to Android Devices}.
|
|
|
|
|
|
|
|
\li Enable debugging on your Android device and connect it to the PC.
|
|
|
|
|
|
|
|
Debugging is enabled in different ways on different Android devices.
|
|
|
|
Look for \gui {USB Debugging} under \gui {Developer Options}. On
|
|
|
|
some devices \gui {Developer Options} is hidden and becomes visible
|
|
|
|
when you tap the \gui {Build number} field in \gui Settings >
|
|
|
|
\gui About several times.
|
|
|
|
|
|
|
|
\endlist
|
|
|
|
|
|
|
|
\section1 Using the Android Emulator
|
|
|
|
|
|
|
|
To run your application on the Android Emulator, you must create Android
|
|
|
|
virtual devices (AVD). Select \gui Tools > \gui Options > \gui Android >
|
|
|
|
\gui Add. If you run an application without a device connected to the
|
|
|
|
development PC and without an AVD specified, \QC asks you to add an AVD.
|
|
|
|
|
|
|
|
To manage AVDs, select \gui {Start Android AVD Manager}.
|
|
|
|
|
|
|
|
\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
|
|
|
|
|
2013-02-15 15:10:45 +01:00
|
|
|
\QC is integrated with the GDB and GDB server that are delivered with the
|
|
|
|
Necessitas SDK. It provides GDB with Python support that enables \QC to
|
|
|
|
display custom Qt types, such as QString, QObject, and so on.
|
|
|
|
|
2012-07-24 15:31:23 +02:00
|
|
|
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
|
|
|
|
the run settings for the project, in the \gui {Android target SDK} field,
|
|
|
|
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.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|