Sign up for the KDAB Newsletter
Stay on top of the latest news, publications, events and more.
Go to Sign-up
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:
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 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:
if(ANDROID)
set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android" CACHE INTERNAL "")
endif()
The CACHE is mandatory, otherwise QtCreator won't see the variable and it won't use it
if(ANDROID)
if (ANDROID_ABI STREQUAL "armeabi-v7a")
set(ANDROID_EXTRA_LIBS ${CMAKE_CURRENT_SOURCE_DIR}/3rd-party/android_armeabi-v7a/ssl/libcrypto.so ${CMAKE_CURRENT_SOURCE_DIR}/3rd-party/android_armeabi-v7a/ssl/libssl.so CACHE INTERNAL "")
endif()
endif()
The previous snippet will add libcrypto.so and libssl.so 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.
Stay on top of the latest news, publications, events and more.
Go to Sign-up
Upgrade your applications from Qt 5 to Qt 6 with KDAB’s migration services. Get a free migration assessment and join a hands-on workshop to prepare your team for a successful transition!
Learn more
Learn Modern C++
Our hands-on Modern C++ training courses are designed to quickly familiarize newcomers with the language. They also update professional C++ developers on the latest changes in the language and standard library introduced in recent C++ editions.
Learn more
14 Comments
11 - Dec - 2018
Crstian
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. http://doc.qt.io/qtcreator/creator-deployment-embedded-linux.html It would so much better if there would be some cross platform support for the "installed" targets.
11 - Dec - 2018
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 ;-).
12 - Dec - 2018
Sune
Shouldn't this use "the cmake way" of make install rather than copying it manually over?
12 - Dec - 2018
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 ;-).
6 - Mar - 2019
BogDan Vatra
Sadly, the CMake support was postponed for the next QtCreator version.
11 - Dec - 2018
Jean-Michaël Celerier
11 - Dec - 2018
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 ;-).
21 - Feb - 2019
Markus
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/libQt5Gui.so: 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.
6 - Mar - 2019
BogDan Vatra
Sadly, the CMake support was postponed for the next QtCreator version.
6 - Mar - 2019
Kyle
So it is now planned for Qt Creator 4.10?
6 - Mar - 2019
BogDan Vatra
That's my hope
6 - Mar - 2019
BogDan Vatra
I just merge the patch a few minutes ago, so it will be part of QtCreator 4.10
7 - Mar - 2019
Kyle
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.
20 - Jun - 2019
Roman
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 https://github.com/qt-creator/qt-creator/blob/master/src/plugins/android/androidbuildapkstep.cpp 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?