Qt client on Android

Do you want to help out with Freeciv development? Then check out this forum.
louis94
Hardened
Posts: 218
Joined: Thu Apr 25, 2013 10:17 pm
Location: Belgium

Qt client on Android

Postby louis94 » Mon Aug 19, 2019 5:45 pm

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:
Screenshot_20190819_145828.png

My modified version of freeciv can be found at https://github.com/lmoureaux/freeciv/co ... 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/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 \
            --target=i386-linux-android21
            --host=x86_64-linux-gnu \
            --disable-server \
            --disable-nls \
            --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


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).

Instructions to make the apk are provided in the repo under bootstrap/android/make-apk.sh; this will eventually be integrated to the build system.

[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

louis94
Hardened
Posts: 218
Joined: Thu Apr 25, 2013 10:17 pm
Location: Belgium

Re: Qt client on Android

Postby louis94 » Fri Sep 13, 2019 9:45 am

The repo has been updated with touch support for scrolling the map. This means the game can be played.