Despite my involvement in KDE and free software operating systems, one of the features I’ve always loved from Qt is how we can use it to develop an application that can be used on any platform. Since I got my first /programmable/ phone, I’ve wanted to get my projects to work there, especially through all Nokia approaches to the issue, and I’ve managed to do so with relative success.
At some point last year I got to the conclusion that, if I wanted to remain somewhat sane, the best approach was to start focusing Android by caring about the CMake side of the issue and let QtQuick get into place, which is not in place yet, but admittedly in a much better state than a couples of years ago.
My KDE on Android approach is that any KDE project should be able to be built and bundled for Android from the sources, that is with an apk file as a result, without having to change the project sources: c++ or cmake.
I started working on this longtime ago on Qt4, but the fact that kdelibs was about to change and the poor direction of the port drove me away from bothering. Also if we want portable interfaces we want QtQuick Controls. I don’t think there’s much doubt there.
I restarted the project last November. I compiled a full Qt5 installation and started to get it to build, my intention was to use android.toolchain.cmake again, but I then decided that it would be better to create a new cmake toolchain file to have all the control I needed over how it’s being compiled. Some things need to be treated with special love like how executables are built and especially being able to create apks.
At the moment it seems to be working reasonably well, I’ve been using KAlgebra as a test. I get to easily deploy the Analitza framework which is a dependency and then consume it from KAlgebra which bundles all dependencies into a nice publishable APK.
Enough back-story, let’s see how we’d build KAlgebra (or any traditional KDE project for that matter).
To get all the features going we need:
* Qt 5.4 built for Android (currently in dev branch)
* CMake 3.0
* Android NDK
* Android Development Kit
* the ToolChain file I created (still to find a proper place, can be found here)
* Extra-CMake-Modules
* The project’s source code, because the power is in the source!
Here’s an example on how to get it done [1], but that’s the expanded version. As an attempt not to scare you here I used a simplified version, by having a cmakeandroid
macro defined, passing cmake all the needed information.
mkdir build-analitza build-kalgebra
cd build-analitza && cmakeandroid ~/src/analitza && make && make install
cd build-kalgebra && cmakeandroid ~/src/kalgebra -DQTANDROID_EXPORTED_TARGET=kalgebramobile && make && make create-apk-kalgebramobile
Which I think it’s readable enough.
To conclude, we are able to consider Android as a candidate for KDE projects to adopt. There’s much more to do both on KDE, Qt and cmake sides, but we can get to discuss it when you’ve ported your application.
For the moment, I’d like to know if there’s any application that is interested in being built for Android, I’d like to give it a try, especially if it’s already been ported to QtQuick and Qt5/KF5.
Furthermore, in case anybody is interested, I’ll open a wiki page with this information, in case anybody wants to use it, for the moment my cmake toolchain and manifest can be found here:
http://quickgit.kde.org/?p=scratch%2Fapol%2Fkalgebraandroid.git
[1]
mkdir install && \
mkdir build-analitza && cd build-analitza && \
/opt/cmake-devel/bin/cmake ~kde-devel/frameworks/analitza -DCMAKE_INSTALL_PREFIX=$HOME/android/install -DCMAKE_PREFIX_PATH=$HOME/android/install -DANDROID_APK_DIR=$HOME/android/kalgebraandroid/androidpkg/ -DCMAKE_TOOLCHAIN_FILE=$HOME/android/kalgebraandroid/AndroidToolchain.cmake -DQt5_DIR=$HOME/android/qt5/qtbase/lib/cmake/Qt5/ -DQt5Core_DIR=$HOME/android/qt5/qtbase/lib/cmake/Qt5Core && \
make && make install && \
cd .. && mkdir build-kalgebra && cd build-kalgebra && \
/opt/cmake-devel/bin/cmake ~kde-devel/frameworks/kalgebra -DCMAKE_INSTALL_PREFIX=$HOME/android/install -DCMAKE_PREFIX_PATH=$HOME/android/install -DANDROID_APK_DIR=$HOME/android/kalgebraandroid/androidpkg/ -DCMAKE_TOOLCHAIN_FILE=$HOME/android/kalgebraandroid/AndroidToolchain.cmake -DQt5_DIR=$HOME/android/qt5/qtbase/lib/cmake/Qt5/ -DQt5Core_DIR=$HOME/android/qt5/qtbase/lib/cmake/Qt5Core -DQTANDROID_EXPORTED_TARGET=kalgebramobile -DMOBILE_BACKEND=qtcontrols && \
make && \
make create-apk-kalgebramobile
While it’s not a KDE app, I’d love to see speedcrunch ported to android.
This is awesome! Can’t wait to play with these ported programs!
Okular would be really nice. To me, this is the best PDF reader and presentation applikation.
Amarok could also be interesting
Great work !
I’d like to see ksirk and kgraphviewer ported, but I should switch them to Qt5/QtQuick before…
#5 is there anything you need to happen, besides free time? 🙂
Is it really easier to port an application to Qt Quick than to make the Qt Widgets UI easily usable on touchscreens?
I know that typical Android UIs are mostly not based on widget sets, but I think that’s mostly because the build-in widget set is not rich enough. Not using a widget set has the same consequences as it would on the desktop: UIs are ad-hoc looking, ugly, and the programmers waste time.
Do Qt Quick Controls applications integrate with the platforms’ widget sets on KDE and other desktop platforms?
#7 I haven’t seen a good QtWidgets UI on a touch screen so far. I can be wrong though.
And yes, QtQuick Controls integrates with KDE, Windows, Mac OS X and it’s on the works to support Android on 5.4. I agree that not integrating with the OS look and feel is definitely bad, we want to integrate and Qt knows how to do that.
Hola!!
Gran noticia, que me parece muy prometedora!
Quizás F-droid serÃa un buen sitio donde encontrar ese software de KDE!! 😉
Saludos y muchas gracias por tu trabajo!!
‘ve phun!
“And yes, QtQuick Controls integrates with KDE, Windows, Mac OS X and it’s on the works to support Android on 5.4”
That’s great!
#10 Gracias! 🙂 I had some discussions with an F-Droid developer during FOSDEM, it looks doable and I think it’s an awesome place for us to be. 🙂
A wiki page about it would be amazing!
Thanks for this interesting work.
I think you know this already, cause they where in Randa too:
http://www.gcompris.net
is a KDE and Android App.
They are very active an did a lot of improvements on Android, so i think they learned a lot on porting to Android they could share with you.
Please….Okular!
riessmi: Yes, we’re already collaborating with GCompris.
kiers: Yes! you can give it a test here:
https://binary-factory.kde.org/view/Android/job/Okular_android/