Skip to content

QtCreator CMake for Android plugin

Santa Claus is coming to … wait a minute, it’s not Christmas yet!

Status update: The patch was merged into master branch on Mar 6th, therefore it will be part of QtCreator 4.10(5.0?) not 4.9!

I have the pleasure to let you know that KDAB has contributed to Qt with yet another super cool project! It’s about QtCreator CMake for Android! I know it’s a strange coincidence between this article and The Qt Company’s decision to ditch QBS and use CMake for Qt 6, but I swear I started to work on this project *before* they announced it 🙂 ! This plugin enables painless experience when you want to create Android apps using Qt, CMake and QtCreator. It’s almost as easy as Android Qmake QtCreator plugin! The user will build, run & debug Qt on Android Apps as easy as it does with Qmake. Before I go into the boring details, let’s see what the requirements are and, more importantly, when it will be available! Requirements:

  • cmake 3.7 or newer (needed for server support in QtCreator)
  • NDKr18 or newer (only Clang and libc++ shared are supported)
  • Qt 5.12.1 (was too late for this patch to get in 5.12.0)

When will it be available? Well, I started the blog with the Santa on purpose, because, sadly, it’s too late to push it in QtCreator 4.8 and it will be available in the next version (4.9). If you can’t wait for QtCreator 4.9 and you like to try it sooner, you can apply this patch on top of QtCreator’s master branch. Now back to technical details, in order to build your Qt Android application, this plugin must do some magic:

  • after it builds the C++ bits, it copies all the targets (DynamicLibraries) into “{build_folder}/android/libs/{arch}”
  • generates android_deployment_settings.json, which is needed by androiddeployqt tool

After this step, androiddeployqt will complete your Android Qt APK by copying all the Qt dependencies (libs & resources). Last but not least, these are qmake features that you’ll not find in cmake:

  • IDE management for ANDROID_PACKAGE_SOURCE_DIR yes, it supports even the same naming as qmake. You’ll need to add the following piece of cmake script to your CMakeLists.txt file:

    The CACHE is mandatory, otherwise QtCreator won’t see the variable and it won’t use it

  • IDE support ANDROID_EXTRA_LIBS, you’ll need to add the next piece of CMake script to your CMakeLists.txt file
        if (ANDROID_ABI STREQUAL "armeabi-v7a")
            set(ANDROID_EXTRA_LIBS ${CMAKE_CURRENT_SOURCE_DIR}/3rd-party/android_armeabi-v7a/ssl/ ${CMAKE_CURRENT_SOURCE_DIR}/3rd-party/android_armeabi-v7a/ssl/ CACHE INTERNAL "")

    The previous snippet will add and files ONLY for armeabi-v7a android ABI.

Note: KDAB offers training in CMake, including all the latest tips from our trainers, who are all active developers.

14 thoughts on “QtCreator CMake for Android plugin”

  1. Does it pack just the shared objects? Wouldn’t be nice if this would have something to do with “install” step of CMake?
    At the moment Qt Creator has some deployment support via QtCreatorDeployment.txt, but one has to manually set it up, which is a pain.
    It would so much better if there would be some cross platform support for the “installed” targets.

    1. BogDan Vatra

      Currently it packs all shared objects.
      Install step will be very difficult with cmake, because the shared objects must go in some special folders (libs/arm64-v8a, libs/armv7a, etc).
      That’s the reason why I chose to copy those libs from QtCreator and not using cmake ;-).

      1. Shouldn’t this use “the cmake way” of make install rather than copying it manually over?

        1. BogDan Vatra

          Well, if an user really insist to use “the cmake way” you can disable the “Magic” QtCreator step and add one in which you do the “make install”, but be aware that you’ll need to set the right paths before doing that.
          My goal was (still is and it will be) to create a painless experience for the users ;-).

  2. > after it builds the C++ bits, it copies all the targets (DynamicLibraries) into “{build_folder}/android/libs/{arch}”
    generates android_deployment_settings.json, which is needed by androiddeployqt tool
    nice ! it would be great if QtCreator had the same level of integration with CMake for building and deploying, e.g. macos bundles, windows installers, and dare I say AppImages …

    1. BogDan Vatra

      Hehe, I’m going to tell you a secret, I did this plugin (and also the android qmake one) because I’m way too lazy to build, deploy & debug cmake Qt apps manually on Android ;-).

  3. Is there an example project that creates an Android app with CMake? I have installed Qt 5.12.1 and QtCreator 4.9.0-beta1, but I’m not sure how to do this. I assumed that I can use the same CMakeLists.txt that I use for building on the desktop version (which uses add_executable()) also for the Android app, just like I could use the same qmake project for both the desktop version and the Android app. But I get an error at link time:

    Qt/5.12.1/android_armv7/lib/ error adding symbols: file in wrong format

    Or do I need a separate CMakeLists.txt for the Android app with a shared library target? A simple example project how to set this up would be really helpful.

          1. Thank you for keeping us posted, and, most of all, thank you for developing this. I am looking forward to trying it out once Qt Creator 4.10 is released.

  4. Hi Bogdan,

    Thanks for this work, this plugin is very helpful!

    I just installed QtCreator 4.10-beta1 and was able to build our project.
    However, it fails at “Build Android APK” step with the error:
    “Cannot set up Android, not building an APK.”

    I checked the source code of the plugin at and it looks like there can be multiple causes of this error.
    Is it possible to add specific or more detailed error messages for each type issue?

Leave a Reply

Your email address will not be published. Required fields are marked *