Android: improve documentation and setup script

This has now been verified to work on a fresh clean Ubuntu 20.04 install, both
using the docker image route as well as the full local build system.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2020-11-27 22:18:39 +00:00
parent dbf2e3a857
commit fb3d1b3073
2 changed files with 57 additions and 48 deletions

View file

@ -1,61 +1,70 @@
Tool repo to crosscompile subsurface to android-arm over-simplistic instructions to building the Android package from source
--------------------------------------------------- ------------------------------------------------------------------------
Dependencies: The easiest way to build things is using our container:
1. android_sdk, android_ndk and Qt for android. See step 0. mkdir $HOME/src
2. cmake cd $HOME/src
3. ant git clone git://github.com/subsurface/subsurface
4. Java JDK cd subsurface
5. working adb is recommended git checkout version or branch you are testing
6. dependencies of libdivecomputer and subsurface - cd ..
visit http://subsurface.hohndel.org/documentation/building/ sudo docker run -v $HOME/src/subsurface:/android/subsurface -w /android --name=android-builder-docker -d subsurface/android-build-container:5.15.1 /bin/sleep 60m
sudo docker exec -t android-builder-docker git config --global user.email "ci@subsurface-divelog.org"
sudo docker exec -t android-builder-docker git config --global user.name "Subsurface CI"
sudo docker exec -t android-builder-docker apt-get install --reinstall cpp-7 gcc-7-base libgcc-7-dev libcc1-0 gcc-7
sudo docker exec -t android-builder-docker /bin/bash -x ./subsurface/packaging/android/qmake-build.sh
By far the easiest way to do this is using the Android build container which is
used to create the official builds. That has all the dependencies ready and
makes things a lot easier.
Run the docker image: docker://subsurface/android-builder:5.13.10 alternatively you can build locally without the help of our container.
Check out the sources inside the container, make sure the following links Setup your build environment on a Ubuntu 20.04 Linux box
are available in parallel to the source directory
ln -s /android/Qt . I think these packages should be enough:
ln -s /android/android-ndk-r18b . sudo apt-get update
ln -s /android/android-sdk-linux . 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
and run the build wrapper from the directory above the source directory 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
bash -x subsurface/packaging/android/android-build-wrapper.sh git clone git://github.com/subsurface/subsurface
This should create a pair of unsigned but otherwise working APKs (for 32 and 64 # now get the SDK, NDK, Qt, everything that's needed
bit ARM). bash /android/subsurface/packaging/android/android-build-setup.sh
Alternatively, steps to install using your own Linux machine: Once this has completed, you should have a working build environment.
Step 0. bash -x subsurface/packaging/android/qmake-build.sh
Grab..
Android ndk from: http://developer.android.com/tools/sdk/ndk/index.html
Android sdk from: http://developer.android.com/sdk/index.html#download
And QT for android from: http://qt-project.org/downloads
Step 1. should build a working .aab as well as a .apk that can be installed on
Extract and install these into known directories. your attached device:
Have a look in the top of build.sh for where the cross build tool expects
them. By default thats is: ../../../android-ndk-r9d ../../../android-sdk-linux
and ../../../Qt/5.5 (or Qt/5.6)
Step 2. ./platform-tools/adb install ./subsurface-mobile-build/android-build/build/outputs/apk/debug/android-build-debug.apk
Run bash build.sh in the terminal. By default it builds for arm but you
can pass x86 as first arg to build.sh to have it build for x86. Nice when
debugging in a fast emulator.
The script will download and build the whole dependency chain.
After this, subsurface will be built for android. Note that since you don't have the same signing key that I have,
you'll have to uninstalled 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.
The output folder is subsurface-build-arm/android_build and your newly
created apk shows up as:
subsurface-build-arm/android_build/bin/QtApp-debug.apk
Where the x86 apk shows up when built for x86 is left as a exercise for the
reader.

View file

@ -52,11 +52,11 @@ yes | sdkmanager --sdk_root=/android --licenses
# next check that Qt is installed # next check that Qt is installed
if [ ! -d "$LATEST_QT" ] ; then if [ ! -d "$LATEST_QT" ] ; then
pip3 install aqtinstall pip3 install aqtinstall
aqt install -O /android "$LATEST_QT" linux android -m qtcharts $HOME/.local/bin/aqt install -O /android "$LATEST_QT" linux android -m qtcharts
fi fi
# now that we have an NDK, copy the font that we need for OnePlus phones # now that we have an NDK, copy the font that we need for OnePlus phones
# due to https://bugreports.qt.io/browse/QTBUG-69494 # due to https://bugreports.qt.io/browse/QTBUG-69494
cp "$ANDROID_HOME"/platforms/"$ANDROID_PLATFORMS"/data/fonts/Roboto-Regular.ttf "$SUBSURFACE_SOURCE"/android-mobile || exit 1 cp "$ANDROID_HOME"/platforms/"$ANDROID_PLATFORMS"/data/fonts/Roboto-Regular.ttf "$SCRIPTDIR"/../../android-mobile || exit 1
echo "things are set up for the Android build" echo "things are set up for the Android build"