Faster loading of Qt apps on Android17 Feb 2014
*Edit: In QtCreator 3.1, the method used here (using resource files)
will become the default way to perform deployment on all platforms.
I.e., this guide is only useful if you have created your project using
QtCreator < 3.1.
If your Qt application is taking too long to load on Android, it is likely because accessing asset-files is really slow on some devices. I just tested an application with about 12 QML-files and it took 40(!) seconds to load. This appears to have been an issue for quite some time, and although efforts have been made to reduce the problem, my app still loads too slow on my Asus Transformer TF300T. In Qt and Android’s defence, this device is known for its extremely slow eMMC storage.
The cure in my case was to use a Qt Resource Collection file for all my QML assets. In Qt Creator, this is as simple as clicking File > New File or Project > Qt > Qt Resource file and then add a prefix “/” before adding all files from each QML folder. After creating and setting up the .qrc-file, I changed the URL in my main-function to “qrc:/qml/myproject/main.qml”.
This worked flawlessly, and the load time dropped from 40 seconds to less than a second!
You should of course be careful with what you add to your resource file. All listed files will be compiled into your executable, so if there are files you don’t want loaded right away, you might want to keep them outside your .qrc file.
The only downside with this approach is adding all new QML files to the resource file. This is a bit tedious in the long run, so I suppose I will automate it with a script.