Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
168 changes: 168 additions & 0 deletions .github/autobuild/android.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
#!/bin/bash
set -eu

COMMANDLINETOOLS_VERSION=6858069
ANDROID_NDK_VERSION=r21d
ANDROID_PLATFORM=android-30
ANDROID_BUILD_TOOLS=30.0.2
AQTINSTALL_VERSION=2.0.6
QT_VERSION=6.2.3

# This list has to match Jamulus.pro's ANDROID_ABIS, but we can't extract it automatically as names differ slightly:
ABIS=(x86 x86_64 armv7 arm64_v8a)

if [[ "${QT_VERSION}" =~ 5\..* ]]; then
JAVA_VERSION=8
else
JAVA_VERSION=11
fi

# Only variables which are really needed by sub-commands are exported.
# Definitions have to stay in a specific order due to dependencies.
QT_BASEDIR="/opt/Qt"
ANDROID_BASEDIR="/opt/android"
BUILD_DIR=build
export ANDROID_SDK_ROOT="${ANDROID_BASEDIR}/android-sdk"
export ANDROID_NDK_ROOT="${ANDROID_BASEDIR}/android-ndk"
COMMANDLINETOOLS_DIR="${ANDROID_SDK_ROOT}"/cmdline-tools/latest/
ANDROID_NDK_HOST="linux-x86_64"
ANDROID_SDKMANAGER="${COMMANDLINETOOLS_DIR}/bin/sdkmanager"
export JAVA_HOME="/usr/lib/jvm/java-${JAVA_VERSION}-openjdk-amd64/"
export PATH="${PATH}:${ANDROID_SDK_ROOT}/tools"
export PATH="${PATH}:${ANDROID_SDK_ROOT}/platform-tools"

if [[ ! ${jamulus_buildversionstring:-} =~ [0-9]+\.[0-9]+\.[0-9]+ ]]; then
echo "Environment variable jamulus_buildversionstring has to be set to a valid version string"
exit 1
fi

setup_ubuntu_dependencies() {
export DEBIAN_FRONTEND="noninteractive"
EXTRA_PKGS=("")
if [[ ! "${QT_VERSION}" =~ 5\..* ]]; then
# Qt6 depends on this:
EXTRA_PKGS=("libglib2.0-0")
fi

sudo apt-get -qq update
sudo apt-get -qq --no-install-recommends -y install build-essential zip unzip bzip2 p7zip-full curl chrpath "openjdk-${JAVA_VERSION}-jdk-headless" "${EXTRA_PKGS[@]}"
}

setup_android_sdk() {
mkdir -p "${ANDROID_BASEDIR}"

if [[ -d "${COMMANDLINETOOLS_DIR}" ]]; then
echo "Using commandlinetools installation from previous run (actions/cache)"
else
mkdir -p "${COMMANDLINETOOLS_DIR}"
curl -s -o downloadfile "https://dl.google.com/android/repository/commandlinetools-linux-${COMMANDLINETOOLS_VERSION}_latest.zip"
unzip -q downloadfile
mv cmdline-tools/* "${COMMANDLINETOOLS_DIR}"
fi

yes | "${ANDROID_SDKMANAGER}" --licenses
"${ANDROID_SDKMANAGER}" --update
"${ANDROID_SDKMANAGER}" "platforms;${ANDROID_PLATFORM}"
"${ANDROID_SDKMANAGER}" "build-tools;${ANDROID_BUILD_TOOLS}"
}

setup_android_ndk() {
mkdir -p "${ANDROID_BASEDIR}"
if [[ -d "${ANDROID_NDK_ROOT}" ]]; then
echo "Using NDK installation from previous run (actions/cache)"
else
curl -s -o downloadfile "https://dl.google.com/android/repository/android-ndk-${ANDROID_NDK_VERSION}-linux-x86_64.zip"
unzip -q downloadfile
mv "android-ndk-${ANDROID_NDK_VERSION}" "${ANDROID_NDK_ROOT}"
fi
}

setup_qt() {
if [[ -d "${QT_BASEDIR}" ]]; then
echo "Using Qt installation from previous run (actions/cache)"
else
echo "Installing Qt..."
python3 -m pip install "aqtinstall==${AQTINSTALL_VERSION}"
python3 -m aqt install-qt --outputdir "${QT_BASEDIR}" linux android "${QT_VERSION}" \
--archives qtbase qttools qttranslations qtandroidextras
QT_ARCHIVES=(qtbase qttools qttranslations)
if [[ "${QT_VERSION}" =~ 5\..* ]]; then
QT_ARCHIVES+=(qtandroidextras)
python3 -m aqt install-qt --outputdir "${QT_BASEDIR}" linux android "${QT_VERSION}" --archives "${QT_ARCHIVES[@]}"
else
# From Qt6 onwards, each android ABI has to be installed individually.
local abi
for abi in "${ABIS[@]}"; do
python3 -m aqt install-qt --outputdir "${QT_BASEDIR}" linux android "${QT_VERSION}" "android_${abi}" --archives "${QT_ARCHIVES[@]}"
done

# In addition, android no longer provides a full qmake binary. Instead, it's just a script.
# We need to install the regular Linux desktop qmake instead.
# Qt6 is also linked to rather exotic versions of libicu, therefore, we need to install those prebuilt libs as well:
python3 -m aqt install-qt --outputdir "${QT_BASEDIR}" linux desktop "${QT_VERSION}" --archives qtbase icu
fi
fi
}

build_app_as_apk() {
local MAKE="${ANDROID_NDK_ROOT}/prebuilt/${ANDROID_NDK_HOST}/bin/make"
local DEPLOYMENT_SETTINGS="android-Jamulus-deployment-settings.json"
local ARCHITECTURES=""
local abi
for abi in "${ABIS[@]}"; do
if [[ "${QT_VERSION}" =~ 5\..* ]]; then
QMAKE="${QT_BASEDIR}/${QT_VERSION}/android/bin/qmake"
ANDROIDDEPLOYQT="${QT_BASEDIR}/${QT_VERSION}/android/bin/androiddeployqt"
else
# From Qt6 onwards, there is no single android directory anymore.
# Instead, there's one per ABI. As qmake handles ABIs itself, we just pick
# one here:
QMAKE="${QT_BASEDIR}/${QT_VERSION}/android_${abi}/bin/qmake"
# In Qt6, androiddeployqt is part of the desktop qtbase, not the android* qtbase:
ANDROIDDEPLOYQT="${QT_BASEDIR}/${QT_VERSION}/gcc_64/bin/androiddeployqt"
fi

"${QMAKE}" -spec android-clang
"${MAKE}" -j "$(nproc)"
"${MAKE}" INSTALL_ROOT="${BUILD_DIR}" -f Makefile install
if [[ "${QT_VERSION}" =~ 5\..* ]]; then
# Qt5 performs all ABI builds in one go
break
fi
[[ -z "${ARCHITECTURES}" ]] || ARCHITECTURES="${ARCHITECTURES}, "
ARCHITECTURES="${ARCHITECTURES}$(grep -oP '"architectures":\s*\{\K[^}]+(?=\})' "${DEPLOYMENT_SETTINGS}")"
"${MAKE}" clean
done
if [[ ! "${QT_VERSION}" =~ 5\..* ]]; then
sed -re 's/("architectures":\s*\{).*(\}.*)/\1'"${ARCHITECTURES}\2/" -i "${DEPLOYMENT_SETTINGS}"
fi

"${ANDROIDDEPLOYQT}" --input "${DEPLOYMENT_SETTINGS}" --output "${BUILD_DIR}" \
--android-platform "${ANDROID_PLATFORM}" --jdk "${JAVA_HOME}" --gradle
}

pass_artifact_to_job() {
mkdir deploy
artifact_deploy_filename="jamulus_${jamulus_buildversionstring}_android.apk"
echo "Moving ${BUILD_DIR}/build/outputs/apk/debug/build-debug.apk to deploy/${artifact_deploy_filename}"
mv "./${BUILD_DIR}/build/outputs/apk/debug/build-debug.apk" "./deploy/${artifact_deploy_filename}"
echo "::set-output name=artifact_1::${artifact_deploy_filename}"
}

case "${1:-}" in
setup)
setup_ubuntu_dependencies
setup_android_ndk
setup_android_sdk
setup_qt
;;
build)
build_app_as_apk
;;
get-artifacts)
pass_artifact_to_job
;;
*)
echo "Unknown stage '${1:-}'"
exit 1
esac
8 changes: 4 additions & 4 deletions .github/workflows/autobuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ jobs:
- config_name: Android .apk (artifact+codeQL)
target_os: android
building_on_os: ubuntu-20.04
cmd1_prebuild: "./autobuild/android/autobuild_apk_1_prepare.sh"
cmd2_build: "./autobuild/android/autobuild_apk_2_build.sh"
cmd3_postbuild: "./autobuild/android/autobuild_apk_3_copy_files.sh"
cmd1_prebuild: "./.github/autobuild/android.sh setup"
cmd2_build: "./.github/autobuild/android.sh build"
cmd3_postbuild: "./.github/autobuild/android.sh get-artifacts"
run_codeql: true
# Jamulus.pro needs to count git history length for android versioning:
checkout_fetch_depth: '0'
Expand Down Expand Up @@ -196,7 +196,7 @@ jobs:
/opt/Qt
/opt/android/android-sdk
/opt/android/android-ndk
key: ${{ matrix.config.target_os }}-${{ hashFiles('.github/workflows/autobuild.yml', 'autobuild/android/autobuild_apk_1_prepare.sh', 'autobuild/android/install-qt.sh') }}-${{ matrix.config.cmd1_prebuild }}
key: ${{ matrix.config.target_os }}-${{ hashFiles('.github/workflows/autobuild.yml', '.github/autobuild/android.sh') }}-${{ matrix.config.cmd1_prebuild }}

- name: Set up build dependencies for ${{ matrix.config.config_name }}
if: matrix.config.cmd1_prebuild
Expand Down
5 changes: 2 additions & 3 deletions Jamulus.pro
Original file line number Diff line number Diff line change
Expand Up @@ -203,16 +203,15 @@ win32 {
LIBS += -framework AVFoundation \
-framework AudioToolbox
} else:android {
ANDROID_ABIS = armeabi-v7a arm64-v8a x86 x86_64
#ANDROID_ABIS = armeabi-v7a arm64-v8a x86 x86_64
ANDROID_VERSION_NAME = $$VERSION
ANDROID_VERSION_CODE = $$system(git log --oneline | wc -l)
ANDROID_PERMISSIONS += android.permission.MODIFY_AUDIO_SETTINGS android.permission.RECORD_AUDIO
message("Setting ANDROID_VERSION_NAME=$${ANDROID_VERSION_NAME} ANDROID_VERSION_CODE=$${ANDROID_VERSION_CODE}")

# liboboe requires C++17 for std::timed_mutex
CONFIG += c++17

QT += androidextras

# enabled only for debugging on android devices
DEFINES += ANDROIDDEBUG

Expand Down
50 changes: 2 additions & 48 deletions android/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
<?xml version="1.0"?>
<manifest package="com.github.jamulussoftware.jamulus" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="-- %%INSERT_VERSION_NAME%% --" android:versionCode="-- %%INSERT_VERSION_CODE%% --" android:installLocation="auto">
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="28"/>
<uses-sdk android:minSdkVersion="23" android:targetSdkVersion="28"/>

<!-- The following comment will be replaced upon deployment with default permissions based on the dependencies of the application.
Remove the comment if you do not require these default permissions. -->
<!-- %%INSERT_PERMISSIONS -->
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>

<!-- The following comment will be replaced upon deployment with default features based on the dependencies of the application.
Remove the comment if you do not require these default features. -->
Expand All @@ -18,65 +14,23 @@

<supports-screens android:largeScreens="true" android:normalScreens="true" android:anyDensity="true" android:smallScreens="true"/>

<application android:hardwareAccelerated="true" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="-- %%INSERT_APP_NAME%% --" android:extractNativeLibs="true" android:icon="@drawable/icon">
<application android:hardwareAccelerated="true" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="-- %%INSERT_APP_NAME%% --" android:icon="@drawable/icon">
<activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation|mcc|mnc|density" android:name="org.qtproject.qt5.android.bindings.QtActivity" android:label="-- %%INSERT_APP_NAME%% --" android:screenOrientation="landscape" android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<!-- Application arguments -->
<!-- meta-data android:name="android.app.arguments" android:value="arg1 arg2 arg3"/ -->
<!-- Application arguments -->
<meta-data android:name="android.app.lib_name" android:value="-- %%INSERT_APP_LIB_NAME%% --"/>
<meta-data android:name="android.app.qt_sources_resource_id" android:resource="@array/qt_sources"/>
<meta-data android:name="android.app.repository" android:value="default"/>
<meta-data android:name="android.app.qt_libs_resource_id" android:resource="@array/qt_libs"/>
<meta-data android:name="android.app.bundled_libs_resource_id" android:resource="@array/bundled_libs"/>
<!-- Deploy Qt libs as part of package -->
<meta-data android:name="android.app.bundle_local_qt_libs" android:value="-- %%BUNDLE_LOCAL_QT_LIBS%% --"/>
<!-- Run with local libs -->
<meta-data android:name="android.app.use_local_qt_libs" android:value="-- %%USE_LOCAL_QT_LIBS%% --"/>
<meta-data android:name="android.app.libs_prefix" android:value="/data/local/tmp/qt/"/>
<meta-data android:name="android.app.load_local_libs_resource_id" android:resource="@array/load_local_libs"/>
<meta-data android:name="android.app.load_local_jars" android:value="-- %%INSERT_LOCAL_JARS%% --"/>
<meta-data android:name="android.app.static_init_classes" android:value="-- %%INSERT_INIT_CLASSES%% --"/>
<!-- Used to specify custom system library path to run with local system libs -->
<!-- <meta-data android:name="android.app.system_libs_prefix" android:value="/system/lib/"/> -->
<!-- Messages maps -->
<meta-data android:value="@string/ministro_not_found_msg" android:name="android.app.ministro_not_found_msg"/>
<meta-data android:value="@string/ministro_needed_msg" android:name="android.app.ministro_needed_msg"/>
<meta-data android:value="@string/fatal_error_msg" android:name="android.app.fatal_error_msg"/>
<meta-data android:value="@string/unsupported_android_version" android:name="android.app.unsupported_android_version"/>
<!-- Messages maps -->
<!-- Splash screen -->
<!-- Orientation-specific (portrait/landscape) data is checked first. If not available for current orientation,
then android.app.splash_screen_drawable. For best results, use together with splash_screen_sticky and
use hideSplashScreen() with a fade-out animation from Qt Android Extras to hide the splash screen when you
are done populating your window with content. -->
<!-- meta-data android:name="android.app.splash_screen_drawable_portrait" android:resource="@drawable/logo_portrait" / -->
<!-- meta-data android:name="android.app.splash_screen_drawable_landscape" android:resource="@drawable/logo_landscape" / -->
<!-- meta-data android:name="android.app.splash_screen_drawable" android:resource="@drawable/logo"/ -->
<!-- meta-data android:name="android.app.splash_screen_sticky" android:value="true"/ -->
<!-- Splash screen -->
<!-- Background running -->
<!-- Warning: changing this value to true may cause unexpected crashes if the
application still try to draw after
"applicationStateChanged(Qt::ApplicationSuspended)"
signal is sent! -->
<meta-data android:name="android.app.background_running" android:value="false"/>
<!-- Background running -->
<!-- auto screen scale factor -->
<meta-data android:name="android.app.auto_screen_scale_factor" android:value="false"/>
<!-- auto screen scale factor -->
<!-- extract android style -->
<!-- available android:values :
* default - In most cases this will be the same as "full", but it can also be something else if needed, e.g., for compatibility reasons
* full - useful QWidget & Quick Controls 1 apps
* minimal - useful for Quick Controls 2 apps, it is much faster than "full"
* none - useful for apps that don't use any of the above Qt modules
-->
<meta-data android:name="android.app.extract_android_style" android:value="default"/>
<!-- extract android style -->
</activity>
<!-- For adding service(s) please check: https://wiki.qt.io/AndroidServices -->
</application>
Expand Down
90 changes: 0 additions & 90 deletions autobuild/android/autobuild_apk_1_prepare.sh

This file was deleted.

Loading