Qt

Connecting Android Devices

You can connect Android devices to the development PC to build, run, debug, and analyze applications on 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 and run applications 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.

Requirements

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

  • OpenJDK Java Development Kit

    To check whether you have OpenJDK installed, enter the following command:

    java -version

    To install OpenJDK, enter the following command:

    sudo apt-get install openjdk-6-jdk

  • Apache Ant 1.8.0, or later

    To check the Ant version, enter the following command on the command line:

    ant -version

  • A tool chain for building applications for Android devices. You have several options, such as the Android SDK and Android NDK from Google (supported for development with Qt 5) or the Necessitas SDK (supported for development with Qt 4).

Developing with Qt 4

The Necessitas SDK automatically sets the paths to the required software in Qt Creator, but you need to add the Qt version. Qt Creator can then create the necessary kits for you.

To configure connections between Qt Creator and Android devices:

  1. Select Tools > Options > Build & Run > Qt Versions > Add to add the path to qmake path in the Qt for Android SDK.
  2. Select Tools > Options > Android to check the paths to the required software.

    "Android options"

  3. 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.
  4. To create an application, select File > New File or Project > Applications > Qt Quick Application 1 (Built-in Elements) or Qt Quick Application 2 (Built-in Elements) > Choose, and follow the instructions of the wizard. For more information, see Creating Qt Quick Projects.
  5. To specify information for the Android manifest file, select Projects > Run for the Android kit.
  6. Select Details to view the Package configurations. For more information about the options you have, see Specifying Settings for Application Packages.
  7. To specify settings for deploying applications to Android, select Details to view the Deploy configurations. For more information about the options you have, see Deploying Applications to Android Devices.

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

To configure connections between Qt Creator and Android devices:

  1. Select Tools > Options > Android to add paths to the Android NDK and SDK.

    "Android options"

  2. 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.
  3. Select File > New File or Project > Applications > Qt Quick Application 2 (Built-in Elements) > Choose, and follow the instructions of the wizard. For more information, see Creating Qt Quick Projects.
  4. To specify information for the Android manifest file, select Projects > Run for the Android kit.
  5. Select Details to view the Package configurations. For more information about the options you have, see Specifying Settings for Application Packages.
  6. To specify settings for deploying applications to Android, select Details to view the Deploy configurations. For more information about the options you have, see Deploying Applications to Android Devices.
  7. Enable debugging on your Android device and connect it to the PC.

    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.

Using the Android Emulator

To run your application on the Android Emulator, you must create Android virtual devices (AVD). Select Tools > Options > 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 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 emulator-arm command from the command line.

Debugging on Android Devices

Qt Creator is integrated with the GDB and GDB server that are delivered with the Necessitas SDK. It provides GDB with Python support that enables Qt Creator to display custom Qt types, such as QString, QObject, and so on.

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