Page 1 of 1

Qt client on Android

Posted: Mon Aug 19, 2019 5:45 pm
by louis94
This topic is about getting the Qt client ready for Android. There is already a port of the SDL client.

Android is officially supported by Qt through their qmake tool and QtAndroidExtras module. The application is compiled as a dynamic library that is loaded by a Java wrapper.

I managed to compile the Qt client and connect to a remote game from an Android device. Currently, text input and basic interaction are working, including scrolling the map. You better not use a smartphone though. Here's a mandatory screenshot:

My modified version of freeciv can be found at ... ndroid-2.6. Most changes are related to the way tilesets are loaded (apk don't work like traditional Linux packages) and the build system (to build the client as a shared object).

Here's my configure command (for an x86 target):

Code: Select all

export ANDROID_NDK_ROOT=/path/to/android/sdk
export ANDROID_NDK_ROOT=/path/to/android/ndk
export "CPP=$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/i868-linux-android21-clang -E"
export CC=$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/i686-linux-android21-clang
export CXX=$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/i686-linux-android21-clang++
export LD=$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/i686-linux-android-ld
export MOCCMD=/path/to/qt/bin/moc

export MOCCMD=/path/to/qt/bin/moc
./configure --enable-client=qt \
            --disable-fcmp \
            --disable-ruledit \
            --host=x86-linux-android \
            --build=x86_64-linux-gnu \
            --disable-server \
            --disable-nls \
            --with-qt5-root=/path/to/qt \
            --with-qt5-includes=/path/to/qt/include \
            --with-qt5-libs=/path/to/qt/lib \
            --prefix=/ \
            --with-sysroot=$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/sysroot/ \
            --disable-sdl-mixer \
            --enable-shared \
            --disable-static \
            --with-android-sdk $ANDROID_SDK_ROOT \
            --with-android-ndk $ANDROID_NDK_ROOT

Important notes about this configure command:
  • The --with-qt5-root argument can be used only when cross-compiling for Android. Do not add a trailing / or the app will not work
  • The build host must start with x86, x86_64, armeabi-v7a or arm64-v8a
  • ARM builds haven't been tested
You need to build Qt from source. Download a tarball from the website and follow the instructions. You need only QtBase and QtAndroidExtras. Use of a recent Qt release is recommended (I use 5.13.1).

The APK can be built using a custom target:

Code: Select all

make apk

[edit 2019-08-20] Added some required env vars
[edit 2019-09-19] Updated configure command for cross-compilation; scrolling the map works; added Qt instructions
[edit 2019-09-28] Updated configure command for newly added Android-specific files; first mention of make apk

Re: Qt client on Android

Posted: Fri Sep 13, 2019 9:45 am
by louis94
The repo has been updated with touch support for scrolling the map. This means the game can be played.

Re: Qt client on Android

Posted: Sat Sep 28, 2019 2:00 am
by louis94
I just pushed an update that makes it much easier to create an APK. Most parameters can just be passed to configure (some paths are still hardcoded for Debian-based distros, eg the JVM).

Re: Qt client on Android

Posted: Wed Aug 05, 2020 7:01 am
i think this is very important work for LT-players

Re: Qt client on Android

Posted: Wed Aug 05, 2020 1:33 pm
by louis94
Thank you!! I don't think I will revive this soon, but it is certainly something that I keep in mind.

I agree that a mobile version would be nice for LT... My prototype could connect to remote servers (without password, but it can be added), but was hardly usable on a small screen. Performance was also a concern. The low coding standards of the Qt client and the convoluted architecture of the game meant changes to the UI were hard -- major changes in the Qt client are probably needed before it can work on both mobile and desktop.