Kodi Community Forum
Linux Cross-compile kodi v21.0-Omega aarch64-linux-android - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Support (https://forum.kodi.tv/forumdisplay.php?fid=33)
+--- Forum: General Support (https://forum.kodi.tv/forumdisplay.php?fid=111)
+---- Forum: Linux (https://forum.kodi.tv/forumdisplay.php?fid=52)
+---- Thread: Linux Cross-compile kodi v21.0-Omega aarch64-linux-android (/showthread.php?tid=378154)



Cross-compile kodi v21.0-Omega aarch64-linux-android - nicoescrime25 - 2024-07-11

Hi

I'm trying to cross-compile an aarch64-linux-android v21.0-Omega kodi from a x86_64 Linux.
I would like to automatize it so I'm trying to do that from a docker container but I can't manage to make it work.
Any help debugging that would be very much appreciated.
I don't really understand what is wrong, I think I followed all the instructions in https://github.com/xbmc/xbmc/blob/master/docs/README.Android.md

Here is my command :
command:
docker build --tag 'kodi' . && docker run -it --rm 'kodi' | tee debug.txt

Here is my docker file:
dockerfile:
FROM debian:12

ENV WORK_DIR /app
WORKDIR $WORK_DIR

ENV DEBIAN_FRONTEND=noninteractive

RUN apt update && apt -y upgrade

# Install build dependencies needed to cross-compile Kodi for Android:
RUN apt install -y \
autoconf bison build-essential curl default-jdk flex gawk git gperf lib32stdc++6 \
lib32z1 lib32z1-dev libcurl4-openssl-dev unzip zip zlib1g-dev

# Cross compilation toolchain
RUN apt install -y gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu crossbuild-essential-arm64

# Java
RUN apt install -y openjdk-17-jdk openjdk-17-jre

# Install other tools.
RUN apt install -y jq wget

# Install things to try to fix issues.
RUN apt install -y libbz2-dev liblzma-dev python3 python3-dev

# Install last version of rust.
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
ENV PATH="$HOME/.cargo/bin:$PATH"

#### INSTALLATION KODI ####
# Extract Android SDK
RUN mkdir -p ${WORK_DIR}/android-tools/android-sdk-linux

# Get command line tools from https://developer.android.com/studio/index.html
# Update the link version from time to time...
RUN wget -O sdk-tools-linux.zip https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip
RUN unzip sdk-tools-linux.zip -d android-tools/android-sdk-linux
RUN rm sdk-tools-linux.zip

# Configure Android SDK
ENV SDKMANAGER_HOME ${WORK_DIR}/android-tools/android-sdk-linux/cmdline-tools/bin
RUN yes | ${SDKMANAGER_HOME}/sdkmanager --sdk_root=${WORK_DIR}/android-tools/android-sdk-linux --licenses
RUN ${SDKMANAGER_HOME}/sdkmanager --sdk_root=${WORK_DIR}/android-tools/android-sdk-linux platform-tools
RUN ${SDKMANAGER_HOME}/sdkmanager --sdk_root=${WORK_DIR}/android-tools/android-sdk-linux "platforms;android-34"
RUN ${SDKMANAGER_HOME}/sdkmanager --sdk_root=${WORK_DIR}/android-tools/android-sdk-linux "build-tools;33.0.1"
RUN ${SDKMANAGER_HOME}/sdkmanager --sdk_root=${WORK_DIR}/android-tools/android-sdk-linux "ndk;26.2.11394342"

# Create a key to sign debug APKs
RUN keytool -genkey -keystore ~/.android/debug.keystore -v -alias androiddebugkey \
-dname "CN=Android Debug,O=Android,C=US" -keypass android -storepass android -keyalg RSA \
-keysize 2048 -validity 10000

# Add script
COPY build_kodi.sh /app/build_kodi.sh

# Run the script
ENTRYPOINT cd /app && /app/build_kodi.sh ; tail -f /dev/null

And here is the build_kodi.sh script that I copy and start in the docker :
script:
#!/bin/bash
set -e

KODI_VERSION=$(curl -s -L 'https://api.github.com/repos/xbmc/xbmc/releases' \
| jq -r .[].tag_name | grep -P '^[0-9]+\.[0-9]+\.?[0-9]*-' | sort -nr | head -1)

echo "Last version: $KODI_VERSION"

echo "Java version: $(java --version | head -n 1)"

cd $WORK_DIR

# Get the source code
git clone -b $KODI_VERSION --single-branch https://github.com/xbmc/xbmc kodi
cd $WORK_DIR/kodi

# Build tools and dependencies
cd $WORK_DIR/kodi/tools/depends
./bootstrap

./configure \
--with-tarballs=$WORK_DIR/android-tools/xbmc-tarballs \
--host=aarch64-linux-android \
--with-sdk-path=$WORK_DIR/android-tools/android-sdk-linux \
--with-ndk-path=$(ls -d "$WORK_DIR/android-tools/android-sdk-linux/ndk"/* | head -n 1) \
--prefix=$WORK_DIR/android-tools/xbmc-depends \
--enable-debug=no

# I added "-Wno-int-conversion" to go further.
make CFLAGS="-Wno-int-conversion" -j$(getconf _NPROCESSORS_ONLN)

# Here I also tried to don't take into account the errors and just check for "Dependencies built successfully"
# in the logs as the installation guide mention this trace.
# It goes further but doesn't work.
#make CFLAGS="-Wno-int-conversion" -j$(getconf _NPROCESSORS_ONLN) 2>&1 \
# | tee /dev/tty | grep -q "Dependencies built successfully" || (echo "Failed to build dependencies" ; exit 1)

## Build binary add-ons
cd $WORK_DIR/kodi
make -j$(getconf _NPROCESSORS_ONLN) -C tools/depends/target/binary-addons || (echo "Failed build add-ons" ; exit 1)

# Configure CMake build
cd $WORK_DIR/kodi
make -C tools/depends/target/cmakebuildsys BUILD_DIR=$WORK_DIR/kodi-build \
CMAKE_EXTRA_ARGUMENTS="-DPython3_INCLUDE_DIRS=$(python3 -c "import sysconfig; print(sysconfig.get_path('include'))"
) -DPython3_LIBRARIES=$(python3 -c "import sysconfig; print(sysconfig.get_config_var('LIBDIR'))")" \
|| (echo "Configure CMake build" ; exit 1)

# Build Kodi
cd $WORK_DIR/kodi-build
make -j$(getconf _NPROCESSORS_ONLN) || (echo "Failed build Kodi" ; exit 1)

# Package
make apk

I added the result of two executions here : https://mega.nz/folder/SpQg3QxD#OdvMmHTFy9rq7YOqHIi0xw

The first one is the execution of the script as it is and the error message is :
error 1:
src/libavformat/matroskadec.c:71:10: fatal error: 'bzlib.h' file not found
I found that it could be due to the fact that the libbz2-dev  package is not installed but as you can see in the Dockerfile, it is.

The second one is with the code that search Dependencies built successfully instead of calling
make CFLAGS="-Wno-int-conversion" -j$(getconf _NPROCESSORS_ONLN)
The error message is :
error 2:
-- The CXX compiler identification is Clang 17.0.2
-- The C compiler identification is Clang 17.0.2
-- The ASM compiler identification is Clang with GNU-like command-line
-- Found assembler: /app/android-tools/android-sdk-linux/ndk/26.2.11394342/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android21-clang
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /app/android-tools/android-sdk-linux/ndk/26.2.11394342/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android21-clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /app/android-tools/android-sdk-linux/ndk/26.2.11394342/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android21-clang - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Mirror download location: http://mirrors.kodi.tv
-- Source directory: /app/kodi
-- Build directory: /app/kodi-build
-- Generator: Single-configuration: Release (Unix Makefiles)
-- CMake Version: 3.26.4
-- System type: Android
-- Core system type: android
-- Platform: android
-- CPU: arm64-v8a, ARCH: aarch64
-- Cross-Compiling: TRUE
-- Execute build artefacts on host:
-- Depends based build: 1
-- statx flags found but no linkable function : C library too old ?
-- Could not find hardware support for SSE (missing: _SSE_TRUE _SSE_OK)
-- Could not find hardware support for SSE2 (missing: _SSE2_TRUE _SSE2_OK)
-- Could not find hardware support for SSE3 (missing: _SSE3_TRUE _SSE3_OK)
-- Could not find hardware support for SSSE3 (missing: _SSSE3_TRUE _SSSE3_OK)
-- Could not find hardware support for SSE4.1 (missing: _SSE41_TRUE _SSE41_OK)
-- Could not find hardware support for SSE4.2 (missing: _SSE42_TRUE _SSE42_OK)
-- Could not find hardware support for AVX (missing: _AVX_TRUE _AVX_OK)
-- Could not find hardware support for AVX2 (missing: _AVX2_TRUE _AVX2_OK)
-- NEON optimization enabled
-- Found Git: /usr/bin/git (found version "2.39.2")
-- Found PkgConfig: /app/android-tools/xbmc-depends/x86_64-linux-gnu-native/bin/pkg-config (found version "0.29.2")
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - yes
-- Could NOT find CCache (missing: CCACHE_PROGRAM)
-- Could NOT find ClangFormat (missing: CLANG_FORMAT_EXECUTABLE)
-- Found FlatC Compiler: /app/android-tools/xbmc-depends/x86_64-linux-gnu-native/bin/flatc (found version "23.3.3")
-- Found JsonSchemaBuilder: /app/android-tools/xbmc-depends/x86_64-linux-gnu-native/bin/JsonSchemaBuilder
-- External TexturePacker for KODI_DEPENDSBUILD will be executed during build: /app/android-tools/xbmc-depends/x86_64-linux-gnu-native/bin/TexturePacker
-- Could NOT find Alsa (missing: ALSA_LIBRARY ALSA_INCLUDE_DIR)
-- Could NOT find Avahi (missing: AVAHI_CLIENT_LIBRARY AVAHI_COMMON_LIBRARY AVAHI_CLIENT_INCLUDE_DIR AVAHI_COMMON_INCLUDE_DIR)
-- Could NOT find Bluetooth (missing: BLUETOOTH_LIBRARY BLUETOOTH_INCLUDE_DIR)
-- Could NOT find Bluray (missing: BLURAY_LIBRARY BLURAY_INCLUDE_DIR BLURAY_VERSION) (Required is at least version "0.9.3")
-- Could NOT find CAP (missing: CAP_LIBRARY)
-- Could NOT find Dav1d (missing: DAV1D_LIBRARY DAV1D_INCLUDE_DIR)
-- Could NOT find DBus (missing: DBUS_LIBRARY DBUS_INCLUDE_DIR DBUS_ARCH_INCLUDE_DIR)
-- Could NOT find Cdio (missing: CDIO_LIBRARY CDIO_INCLUDE_DIR)
-- Could NOT find Iso9660pp (missing: ISO9660PP_LIBRARY ISO9660PP_INCLUDE_DIR ISO9660_LIBRARY ISO9660_INCLUDE_DIR CDIO_LIBRARY CDIO_INCLUDE_DIR CDIOPP_INCLUDE_DIR)
-- Could NOT find LCMS2 (missing: LCMS2_LIBRARY LCMS2_INCLUDE_DIR)
-- Could NOT find LircClient (missing: LIRCCLIENT_LIBRARY LIRCCLIENT_INCLUDE_DIR)
-- Could NOT find MicroHttpd (missing: MICROHTTPD_LIBRARY MICROHTTPD_INCLUDE_DIR)
-- Found NFS: /app/android-tools/xbmc-depends/aarch64-linux-android-21-release/lib/libnfs.a
-- Could NOT find Pipewire (missing: PIPEWIRE_LIBRARY PIPEWIRE_INCLUDE_DIR SPA_INCLUDE_DIR) (Required is at least version "0.3.50")
-- Could NOT find Plist (missing: PLIST_LIBRARY PLIST_INCLUDE_DIR)
-- Could NOT find PulseAudio (missing: PULSEAUDIO_LIBRARY PULSEAUDIO_MAINLOOP_LIBRARY PULSEAUDIO_SIMPLE_LIBRARY PULSEAUDIO_INCLUDE_DIR)
-- Could NOT find Python3 (missing: Python3_INCLUDE_DIRS Python3_LIBRARIES Development Development.Module Development.Embed) (Required is exact version "3.11")
CMake Error at cmake/modules/FindPython.cmake:63 (find_library):
  Could not find FFI_LIBRARY using the following names: ffi
Call Stack (most recent call first):
  cmake/scripts/common/Macros.cmake:403 (find_package)
  cmake/scripts/common/Macros.cmake:452 (find_package_with_ver)
  CMakeLists.txt:260 (core_optional_dep)