summaryrefslogtreecommitdiff
path: root/doc/src/android/androiddev.qdoc
blob: e2317d76178308daca0bc612fe32790a54671d0d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
/****************************************************************************
**
** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the Qt Creator documentation.
**
** 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.
**
** 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: https://www.gnu.org/licenses/fdl-1.3.html.
**
****************************************************************************/

    /*!

    \contentspage index.html
    \page creator-developing-android.html
    \previouspage creator-connecting-mobile.html
    \if defined(qtdesignstudio)
    \nextpage creator-developing-generic-linux.html
    \else
    \nextpage creator-developing-baremetal.html
    \endif

    \title Connecting Android Devices

    You can connect Android devices to the development PC to run, debug,
    and analyze applications built for them from \QC.

    If you have a tool chain for building applications for Android devices
    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,
    to build applications for and run them on Android devices. You can also
    allow \QC to automatically configure the kit.

    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.

    \section1 Requirements

    To use \QC to develop Qt applications for Android, you need the following:

    \list

        \li \l{http://www.oracle.com/technetwork/java/javase/downloads/index.html}
            {Java SE Development Kit (JDK)} version 6, or later

        \li \l{http://www.gradle.org}{Gradle} for building application packages
            for Android devices (APK). Gradle is delivered with Qt 5.9, and
            later. Because Gradle scripts are not delivered with Android SDK
            Tools since version 26.0.0, they are delivered with Qt 5.9 and
            5.6.3.

            \note Using Ant to build APKs is no longer supported.

        \li A tool chain for building applications for Android devices provided
            by the \l{http://developer.android.com/tools/sdk/ndk/index.html}
            {Android NDK} from Google.

        \li \l{http://developer.android.com/sdk/index.html}{Android SDK Tools}

            The following Android SDK packages and tools are required for
            development:

            \list
                \li Platform tools
                \li Build tools
                \li At least one SDK platform
            \endlist

        \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

    \section1 Setting Up the Development Environment

    You must download and install the latest Android NDK and SDK, and then
    update or install the tools and packages needed for development. The SDK
    tool used to update and install the other SDK tools and packages depends on
    the Android SDK Tools version that you have installed:

    \list

        \li Android SDK Tools version 25.2.5, or earlier

            Use the
            \l{https://developer.android.com/studio/tools/help/android.html}
            {android} tool that comes with the SDK Tools package. For example,
            on  Ubuntu the following command starts the SDK update:

            \code
            ./android update sdk
            \endcode

        \li Android SDK Tools version 25.3.0, or later

            Use the
            \l{https://developer.android.com/studio/command-line/sdkmanager.html}
            {sdkmanager} command line tool for SDK package management and the
            \l{https://developer.android.com/studio/command-line/avdmanager.html}
            {avdmanager} tool for Android Virtual Device (AVD) management.

    \endlist

    In addition, you must install Qt for Android as part of Qt 5.2, or later.

    For more information, see \l{Qt for Android}.

    \section2 Specifying Android Device Settings

    To configure connections between \QC and Android devices:

    \list 1

        \li Select \uicontrol Tools > \uicontrol Options > \uicontrol Devices >
            \uicontrol Android.

            \image qtcreator-options-android1.png "Android options"

        \li In the \uicontrol {JDK location} field, add the path to the JDK.

            You can use the \inlineimage download.png
            (\uicontrol Download) button to go to the site where you can
            download the JDK. \QC checks the JDK installation and reports
            errors.

        \li In the \uicontrol {Android Settings} group, add paths to the Android
            NDK and SDK.

            You can use the \inlineimage download.png
            (\uicontrol Download) buttons to go to the sites where you can download
            the Android NDK and SDK.

            The SDK Manager checks the Android NDK and SDK installations,
            reports errors, and offers to install the necessary packages.

            \image qtcreator-options-android2.png "Android NDK and SDK checks"

            For more information, see \l {Managing Android SDK Packages}.

        \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 Select \uicontrol File > \uicontrol {New File or Project} > \uicontrol Application >
            \uicontrol {Qt Quick Application} > \uicontrol Choose, and
            follow the instructions of the wizard. For more information, see
            \l{Creating Qt Quick Projects}.

        \li To specify settings for deploying applications to Android, select
            \uicontrol Projects > \uicontrol Run for the \uicontrol Android kit, and then select
            \uicontrol Details to view the \uicontrol {Deploy configurations}. For more
            information about the options you have, see
            \l{Deploying Applications to Android Devices}.

        \li Enable debugging on your Android device.

            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
            when you tap the \uicontrol {Build number} field in \uicontrol Settings >
            \uicontrol About several times.

        \li Connect the Android device to the development PC with a USB cable.
            You might be asked to select a device in the
            \uicontrol {Select Android Devices} dialog.
    \endlist

    \section2 Managing Android SDK Packages

    Since Android SDK Tools version 25.3.0, only a command-line tool,
    \l{https://developer.android.com/studio/command-line/sdkmanager.html}
    {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.

    When you add paths to the Anroid NDK and SDK in the device options, the
    SDK Manager checks that all the necessary SDK packages have been installed.
    If packages are missing or updates are needed, the SDK Manager offers to
    add and remove packages, as necessary. 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.

    To view the installed Android SDK packages, select \uicontrol Tools >
    \uicontrol Options > \uicontrol Devices > \uicontrol Android >
    \uicontrol {SDK Manager}.

    \image qtcreator-android-sdk-manager.png "Android SDK Manager"

    To filter the packages, select \uicontrol Available, \uicontrol Installed,
    or \uicontrol All in \uicontrol {Show Packages}.

    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}.

    To manage packages installed from Android SDK Tools version 25.2.5, or
    earlier, you can use the native Android SDK Manager. The \QC SDK Manager and
    the native SDK Manager are mutually exclusive, because they are used for
    different Android SDK Tools versions. If you have the native SDK Manager
    installed, you can open it by selecting \uicontrol {Native SDK Manager}.

    \section1 Selecting Android Devices

    When you deploy an application to an Android device with Android
    version 4.2 or later, the \uicontrol {Select Android Devices} dialog opens. It
    lists the devices that are connected to the development PC. and their
    status. You can select devices from the \uicontrol {Compatible Devices} list for
    deployment.

    If \QC determines that a device is not ready for deployment, it places the
    device in the \uicontrol {Incompatible Devices} list, with information about the
    issue. For example, you might need to authorize the connection on the
    device. After you authorize the connection on the device, select
    \uicontrol {Refresh Device List}. The device is moved to the
    \uicontrol {Compatible Devices} list and you can select it for deployment.

    Other reasons for placing a device on the \uicontrol {Incompatible Devices} are
    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"

    AVDs are also listed. To create new AVDs, select
    \uicontrol {Create Android Virtual Device}.

    To set a device as the default device for a particular Android architecture,
    select the \uicontrol {Always use this device for architecture} check box. The
    \uicontrol {Select Android Devices} dialog will not appear until you switch to
    another project or restart \QC.

    \section1 Using the Android Emulator

    To run your application on the Android Emulator, you must create Android
    virtual devices (AVD). Select \uicontrol Tools > \uicontrol Options >
    \uicontrol Devices > \uicontrol Android >
    \uicontrol 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 \uicontrol {Start 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.

    \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
    the run settings for the project, in the \uicontrol {Android build 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.

    \note \QC cannot debug applications on Android devices if Android Studio is
    running. If the following message is displayed in the \uicontrol Output
    pane, close Android Studio and try again: \e {Ignoring second debugger -
    accepting and dropping.}

*/