subsurface/packaging/android
=Michael Keller 6fc8310705 CICD: Improve Workflows.
Make multiple improvements to the existing workflows:
- create a shared custom action to deal with version number tracking
  and generation;
- use this action to add the branch name to the version for pull
  request builds;
- create a shared workflow for all debian-ish builds to avoid re-use
  by copy / paste;
- remove potential security risks by eliminating the use of
  pre-evaluated expressions (`${{ ... }}`) inside scripts;
- update outdated GitHub action versions;
- improve the consistency by renaming scripts acording to have a `.sh`
  extension;
- improve naming of generated artefacts for pull requests to include
  the correct version.

@dirkh: Unfortunately this is potentially going to break builds when it is
merged, as there is no good way to 'test' a merge build short of
merging.
We'll just have to deal with the fallout of it in a follow-up pull
request.

Signed-off-by: Michael Keller <github@ike.ch>
2024-05-13 10:19:59 +12:00
..
.gitignore CICD: Add APK Signing for the Android CICD Pipeline. 2024-01-08 19:46:37 +13:00
docker-build.sh Cleanup: Improve (Android) Build Scripts. 2024-05-06 00:45:51 +12:00
install-qt.sh build-system/Android: add missing install-qt.sh 2020-04-27 11:04:29 -07:00
qmake-build.sh CICD: Improve Workflows. 2024-05-13 10:19:59 +12:00
README.md Cleanup: Improve (Android) Build Scripts. 2024-05-06 00:45:51 +12:00
translations.qrc Fix Translation Error in Android Build. 2024-03-16 13:32:02 +13:00

Instructions for building the Android package from source

In a Container

The easiest way to build a .apk package for Android is to use our own docker image that has all of the build components pre-assembled.

All it takes is this:

export GIT_AUTHOR_NAME=<your name>
export GIT_AUTHOR_EMAIL=<email to be used with github>

cd /some/path
git clone https://github.com/subsurface/subsurface
cd subsurface
git submodule init
git submodule update
./packaging/android/docker-build.sh

Caveat: With this build script libdivecomputer is pulled from git in the version specified in the submodule, so if you have changed libdivecomputer make sure to commit any changes and update the git submodule version before building.

This will result in Subsurface-mobile-VERSION.apk to be created in /some/path/subsurface/output/android/.

On a Linux host

alternatively you can build locally without the help of our container.

Setup your build environment on a Ubuntu 20.04 Linux box

I think these packages should be enough:

sudo apt-get update
sudo apt-get install -y \
    autoconf \
    automake \
    cmake \
    git \
    libtool-bin \
    make \
    wget \
    unzip \
    python \
    python3-pip \
    bzip2 \
    pkg-config \
    libx11-xcb1 \
    libgl1-mesa-glx \
    libglib2.0-0 \
    openjdk-8-jdk \
    curl \
    coreutils \
    p7zip-full

sudo mkdir /android
sudo chown `id -un` /android
cd /android
wget https://dl.google.com/android/repository/commandlinetools-linux-6858069_latest.zip
unzip commandlinetools-linux-*.zip

git clone https://github.com/subsurface/subsurface

# now get the SDK, NDK, Qt, everything that's needed
bash /android/subsurface/scripts/docker/android-build-container/android-build-setup.sh

Once this has completed, you should have a working build environment.

bash -x subsurface/packaging/android/qmake-build.sh

should build a working .aab as well as a .apk that can be installed on your attached device:

./platform-tools/adb  install ./subsurface-mobile-build/android-build/build/outputs/apk/debug/android-build-debug.apk

Note that since you don't have the same signing key that I have, you'll have to uninstall the 'official' Subsurface-mobile binary in order for this to work. And likewise you have to uninstall yours before you'll be able to install an official binary again.