
Only Linux cross-compilation to Android is supported.

Prerequisites:
- Install Android NDK (android-ndk-r17c-linux-x86_64.zip) and Android SDK (SDK Tools 25.2.5 and Platform-tools 29.0.2 are known to work)
- Install Qt 5.12+ for Android
- Get KStars source code from Github or KDE
- Some tools are needed for the compilation: sudo apt-get install dos2unix ccache

Set the following environmental variables before building:

export QT_ANDROID=Qt SDK for Android target (e.g. /opt/Qt/5.9.2/android_armv7"}
export CMAKE_ANDROID_NDK=Android NDK path
export ANDROID_SDK_ROOT=Android SDK path
export ANDROID_API_LEVEL=Android API level (currently the minimum is 17)

If you want to generate signed release package set the following variables:

export ANDROID_KEYSTORE=your_keystore_file
export ANDROID_KEYSTORE_ALIAS=your_keystore_alias
export KSTARS_ROOT=KStars Path (e.g. /home/jasem/Projects/kstars)

First build the KF5 dependencies separately:

- Make a build directory in a separate location form source (e.g. /home/jasem/build/kstars-android):

- Run build_kf5.sh and verify that the script builds everything without any problem.

$KSTARS_ROOT/packaging/android/build_kf5.sh

When KF5 are ready, build KStars Lite for Android:

- Install Eigen3, git and other dependencies
- Configure out-of-source build (MinSizeRel build type is recommended for Android):

cmake -B. -H$KSTARS_ROOT -DBUILD_KSTARS_LITE=ON -DCMAKE_TOOLCHAIN_FILE=$CMAKE_ANDROID_NDK/build/cmake/android.toolchain.cmake \
      -DEIGEN3_INCLUDE_DIR=/usr/include/eigen3/ -DCMAKE_INSTALL_PREFIX=$(pwd)/android/export -DCMAKE_BUILD_TYPE=MinSizeRel \
      -DBUILD_KSTARS_LITE=ON -DECM_DIR=/usr/share/ECM/cmake/ -DCMAKE_PREFIX_PATH=$QT_ANDROID \
      -DCMAKE_AR=${ANDROID_NDK}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar

- Compile:

make -j4

- Download and convert the translations:

make convert_translations_to_android

- Install:

make -j4 install

- Generate the Android debug package:

make create-apk-debug-kstars

- Install the Android debug package to your phone:

make install-apk-debug-kstars

- Generate the Android release package:

make create-apk-release-kstars

- To sign a release package:

make sign-apk-kstars

- The debug package location: android/kstars_build_apk/bin/QtApp-debug.apk
  Manual installation: adb install android/kstars_build_apk/bin/QtApp-debug.apk
- The release package location: android/kstars_build_apk/bin/kstars-release-signed.apk
  Manual installation: adb install android/kstars_build_apk/bin/kstars-signed.apk
