Connecting Android Devices
You can connect Android devices to the development PC to run, debug, and analyze applications built for them from Qt Creator.
If you have a tool chain for building applications for Android devices installed on the development PC, you can add it to Qt Creator. You can then add a 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 Qt Creator to automatically configure the kit.
The Android Debug Bridge (adb) command line tool is integrated to Qt Creator 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.
To use Qt Creator to develop Qt applications for Android, you need the following:
- Java SE Development Kit (JDK) version 6, or later
- Gradle for building application packages for Android devices (APK). Gradle is delivered with Qt 5.9, and later.
Note: Using Ant to build APKs is still possible when developing with Qt 5.8 or earlier together with Android SDK tools versions 25.2.5 or earlier, but Ant support has been deprecated since Qt Creator 4.3 and will be removed in a future version.
- A tool chain for building applications for Android devices provided by the Android NDK from Google.
- Android SDK Tools
The following Android SDK packages and tools are required for development:
- Platform tools
- Build tools
- At least one SDK platform
- On Windows, you also need the following:
- MinGW v4.8.0 revision 2
- 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 http://developer.android.com/sdk/win-usb.html.
After installing the driver, try running a few basic adb commands to check that your device responds to them.
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:
- Android SDK Tools version 25.2.5, or earlier
Use the android tool that comes with the SDK Tools package. For example, on Ubuntu the following command starts the SDK update:
./android update sdk
- Android SDK Tools version 25.3.0, or later
In addition, you must install Qt for Android as part of Qt 5.2, or later.
For more information, see Qt for Android.
To configure connections between Qt Creator and Android devices:
- Select Tools > Options > Devices > Android to add paths to the Android NDK and SDK.
You can use the (Download) buttons to go to the sites where you can download the Android NDK and SDK.
- Select the Automatically create kits for Android tool chains check box to allow Qt Creator to create the kits for you. Qt Creator displays a warning if it cannot find a suitable Qt version.
- Select the tool to use for building application packages:
- To use Gradle, select the Use Gradle instead of Ant check box.
- To use Ant, add the path to the Ant executable in the Ant executable field.
Note: Ant support has been deprecated since Qt Creator 4.3. We recommend that you use Gradle instead.
- Select File > New File or Project > Application > Qt Quick Application > Choose, and follow the instructions of the wizard. For more information, see Creating Qt Quick Projects.
- To specify settings for deploying applications to Android, select Projects > Run for the Android kit, and then select Details to view the Deploy configurations. For more information about the options you have, see Deploying Applications to Android Devices.
- Enable debugging on your Android device.
Debugging is enabled in different ways on different Android devices. Look for USB Debugging under Developer Options. On some devices Developer Options is hidden and becomes visible when you tap the Build number field in Settings > About several times.
- Connect the Android device to the development PC with a USB cable. You might be asked to select a device in the Select Android Devices dialog.
Selecting Android Devices
When you deploy an application to an Android device with Android version 4.2 or later, the 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 Compatible Devices list for deployment.
If Qt Creator determines that a device is not ready for deployment, it places the device in the 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 Refresh Device List. The device is moved to the Compatible Devices list and you can select it for deployment.
Other reasons for placing a device on the 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).
AVDs are also listed. To create new AVDs, select Create Android Virtual Device.
To set a device as the default device for a particular Android architecture, select the Always use this device for architecture check box. The Select Android Devices dialog will not appear until you switch to another project or restart Qt Creator.
Using the Android Emulator
To run your application on the Android Emulator, you must create Android virtual devices (AVD). Select Tools > Options > Devices > Android > Add. If you run an application without a device connected to the development PC and without an AVD specified, Qt Creator asks you to add an AVD.
To manage AVDs, select 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
emulator-arm command from the command line.
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 Android build SDK field, select android-10, or higher. For more information about Android API levels, see What is API Level?.
Note: Select a debug build configuration to build the application for debugging.
© 2017 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.