What's New with Qt for Android

Qt 5.15 LTS and Qt for Android

Since many developers use Qt for Android, we want to improve the developer experience. With the upcoming release of Qt 5.15.0, we have revamped the documentation for Android. The new documentation has lots of new content on how to use Qt for Android maximizing its full potential. It explains in more detail how to extend Qt to support more advanced features and enhance integration with Android APIs.  

The main topics that have been improved in the documentation include: 

  • Extending Qt applications to use custom Java classes or assets and the packaging structure. 
  • Dependency version management between the Android Native Development Kit (NDK) and Qt.  
  • How to work with Android services in a multitude of different ways. 
  • How to build and use OpenSSL with Android. Dependencies between the OpenSSL repository supports all Qt versions, both with QMake and CMake. 

In the same context, many Qt examples that had some issues such as layout, scaling, or permissions, has been fixed. Qt 5.15.0 Qt Android Extras comes with a new code example Qt Java Native Interface Messenger (Qt JNI Messenger). The example demonstrates one of the most important topics when using Qt for Android, which is JNI communication. It explains the workflow of invoking methods and exchanging data between Java and Qt. The example serves as a starting point for bridging Qt and Android both ways. 

New to Qt for Android? Check out my recent ‘Getting started with Qt for Android’ on-demand webinar from the Qt Virtual Tech Con 2020 

Ensuring proper integration with Android, the Android native file dialog can now be used by default by opening file(s) and saving operations. The native file dialog also uses Android’s ‘content’ file scheme and conducts additional exception checks, which in the past has caused some occasional crashes. The AndroidManifest.xml no longer sets minSdkVersion and targetSdkVersion values. Instead, you can set thewith the build.gradle file. Android Studio will provide a warning about setting SDK versions in the manifest file. For more information, see the Manifest documentation. 

For the full list of changes, see Platform Changes in Qt 5.15.0. 

Qt Creator 4.12

The latest release of Qt Creator brought substantial improvements for Android development. Qt Creator can now automatically setup for Android SDK, which is the main block for building and running Qt for Android applications. It prompts you to install the needed packages for development. Furthermore, using OpenSSL in your applications is now more straightforward with Qt Creator, allowing you to set up your local path for the library and use it with any project from the kit settings. 
One of the essential features of Qt for Android support was the lack of managing Qt and NDK versions. In the past, Qt Creator could only have one valid NDK at a given time, which can be troubling when dealing with multiple Qt versions and projects. Qt for Android versions relied on the different NDK versions, and it was up to the developer to select and switch to the correct version manually. That is why we introduced a way to manage multiple Qt versions and couple each of them with the appropriate NDK version. Qt Creator keeps track of this using a common configuration file. Additionally, it is possible to use custom NDK paths as desired.

qtcreator-android-auto-setup

Some other changes we have made include the examples list for Android kits showing examples that are tested and known to work on Android devices. The examples that are not shown by default include those that have unsupported features or modules on Android, for example. Also, improvements to the UI design and functionality included the AVD Managerwhich got some flexibility for creating AVDs, as well as the Manifest Editors icon selection. 

For the full list of changes, see Qt Creator 4.12 Android changes. 

Looking Ahead 

To serve Qt mobile users well, we are going to introduce many more updates for supporting Android. We will create more examples, documentation, and functionality, paving the way for easy and advanced development targeted for Android. Stay tuned for brighter Qt for Android future. 

To access all the new features with Qt for Android, download the latest version via our downloads page or update through the maintenance tool.    


Blog Topics:

Comments

Commenting for this post has ended.

?
Lilian
0 points
140 months ago

Thank you guys for your efforts!
I think I'll wait for the Beta to test...

?
Dasun
0 points
140 months ago

I'll keep my fingers crossed for beta!

?
Thiago Macieira
0 points
140 months ago

I've begun working on a "windeployqt" tool too.

You can see the beginnings here:
http://git.hohndel.org/?p=s...
http://git.hohndel.org/?p=s...

Do you think it would be useful to move to qttools?

?
Maurice Kalinowski
0 points
140 months ago

@Thiago, please check the qttools in stable where we are working on windeployqt, with slightly different approach, but working for Win, WinRT and WinPhone. You can also check with fkleint about details.

At least the first patch seems to be clearly a mingw only solution.

?
Steve
0 points
140 months ago

Sounds like a suitably clean separation... it wasn't clear which files needed to be under version control in android projects for 5.1 and so I added them all. I'll wait for the binary betas before giving it a go though.

?
m][sko
0 points
140 months ago

Is it possible to add some java code to generated files for some specific behavior ?

?
Eskil Abrahamsen Blomfeldt
0 points
140 months ago

The preferred way to add Java code is to add your own Java files and subclass the generated files to override its behavior.

If you want, it's also possible to put a modified QtActivity.java for instance in your Android package source, and this will then overwrite the generated QtActivity.java. This will however mean that you need to make sure it's properly updated if you upgrade to a new Qt version.

?
Benoit
0 points
140 months ago

I tried one of the 5.2.0-beta1 snapshots, working great so far, I like the simplicity of the whole process, great, great work! The only thing I am missing is a QtWidgets-free version of QtQuickControls (which is probably the most common use case for Android deplyment) in order to reduce the package size. I can of course compile it myself but that would be useful for many users to have it in the binary package.

?
Eskil Abrahamsen Blomfeldt
0 points
140 months ago

I agree. We'll look into removing the widgets-dependency by default in Qt 5.2.

?
Cyttorak
0 points
140 months ago

What about apk file sizes with all its Qt stuff bundled? Are they compeititive or still needs some wo rk?

?
Eskil Abrahamsen Blomfeldt
0 points
140 months ago

A default "Hello World" APK in Qt Quick 2 which includes the necessary Qt libraries, plugins and imports will be around 9 MB.

?
Cyttorak
0 points
140 months ago

Not too bad I guess :)

?
J
0 points
140 months ago

This is really great news. Good job, Qt team!

?
Thorsten Zachmann
0 points
140 months ago

Is there a possibility like in the old android support to only get the libaries needed into the package? Currently it seems to copy all in with a lot of stuff not needed

?
Eskil Abrahamsen Blomfeldt
0 points
140 months ago

Currently, the auto-detection will be greedy, including all relevant plugins and imports and their dependencies, since we don't have any way to know currently which ones will be used at run-time. The overhead of this is pretty minimal compared to the overhead of the required libraries.

For QML imports, we'll improve this to be smarter, thus only including the ones that are actually used. Work for this is in progress.

It's also possible to completely override the auto-detection manually to specify precisely which libraries, plugins and files should be included. I'd expect this to be an appropriate extra step right before going into production with an app. See the documentation for details on this.

?
Suppaman
0 points
140 months ago

Hi

This "separation" mean it will be some possibility in the future to develop for android (compiling, packaging and deploy) using Visual Studio 2013 through plugin instead to use Qt Creator?

Thank you

?
Robert
0 points
140 months ago

This is a great improvement particularly in for working with several kits and several CPUs like ARM and Intel (coming at some new Samsung tablets).

Just to remind you that child window bugs related
to sizes and positioning of dialogs, etc. child windows are actually show-stoppers for porting QWidgets - based applications. There are about 10 such issues filed in JIRA whereas it could be that there are only 2-3 real issues behind these 10 reports.

Thank you in advance!

?
AndreasL
0 points
140 months ago

This is great news, I've been wanting a cleaner separation for some time. Good job!

?
Filip Piechocki
0 points
140 months ago

First of all I really like where Qt is heading now, Qt Quick 2 with opengl and scenegraph is pretty awesome, but... a lot of Qt features really look like a technology preview rather than final product. It is nice to have new features but it would be better to have existing features refined. Now it looks like KDE4 when it became usable with version 4.5+ but in the meantime I've switched to gnome...