From 4f1eaa594f511e72233aff5c4696358ceeed1597 Mon Sep 17 00:00:00 2001 From: frobino Date: Fri, 10 Jul 2026 17:38:55 +0200 Subject: [PATCH 01/16] Initial script --- build-android.sh | 91 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100755 build-android.sh diff --git a/build-android.sh b/build-android.sh new file mode 100755 index 0000000..bf7f173 --- /dev/null +++ b/build-android.sh @@ -0,0 +1,91 @@ +#!/bin/bash + +# Build script for Android project using RebelFork SDK and Docker + +set -e # Exit on any error + +echo "=== RebelFork Android Build Script ===" + +# Check if we're in the correct directory +if [ ! -f "CMakeLists.txt" ] || [ ! -d "android" ]; then + echo "Error: This script must be run from the project root directory" + echo "Please navigate to the root of your sample-project directory" + exit 1 +fi + +# Clean up any previous SDK downloads +echo "Cleaning up previous SDK files..." +rm -rf rebelfork-sdk-android* + +# Download RebelFork Android SDK +echo "Downloading RebelFork Android SDK..." +if command -v wget >/dev/null 2>&1; then + wget https://github.com/rbfx/rbfx/releases/download/latest/rebelfork-sdk-android-clang-x64-dll-latest.7z -O rebelfork-sdk-android.7z +elif command -v curl >/dev/null 2>&1; then + curl -L https://github.com/rbfx/rbfx/releases/download/latest/rebelfork-sdk-android-clang-x64-dll-latest.7z -o rebelfork-sdk-android.7z +else + echo "Error: Neither wget nor curl is available. Please install one of them." + exit 1 +fi + +# Extract SDK +echo "Extracting SDK..." +7z x rebelfork-sdk-android.7z + +# Find the extracted SDK directory (name may vary) +SDK_DIR=$(find . -maxdepth 1 -type d -name "rebelfork-sdk-android*" | head -n 1) +if [ -z "$SDK_DIR" ]; then + echo "Error: Could not find extracted SDK directory" + exit 1 +fi + +echo "Found SDK directory: $SDK_DIR" + +# Check if Docker is available +if ! command -v docker >/dev/null 2>&1; then + echo "Error: Docker is not installed or not in PATH" + echo "Please install Docker and make sure it's running" + exit 1 +fi + +# Pull the Docker image +echo "Pulling Docker image..." +docker pull mobiledevops/android-sdk-image:36.1.0 + +# Build using Docker +echo "Building Android project with Docker..." +docker run --rm \ + -v "$PWD:/workspace" \ + -w /workspace \ + mobiledevops/android-sdk-image:36.1.0 \ + bash -c " + set -e + echo '=== Inside Docker container ===' + echo 'Current directory:' \$PWD + echo 'Listing files:' + ls -la + + # Try to build using Gradle + if [ -f 'android/gradlew' ]; then + echo 'Using Gradle wrapper...' + cd android && chmod +x gradlew && ./gradlew assembleDebug + else + echo 'Using system Gradle...' + cd android && gradle assembleDebug + fi + + echo 'Build completed!' + echo 'APK files found:' + find . -name '*.apk' 2>/dev/null || echo 'No APK files found' + " + +# Check for the output APK +echo "=== Build Summary ===" +if find android -name "*.apk" 2>/dev/null | grep -q apk; then + echo "SUCCESS: APK files have been generated:" + find android -name "*.apk" 2>/dev/null +else + echo "WARNING: No APK files found. Check the build output above for errors." +fi + +echo "Build script completed." \ No newline at end of file From 7661566a2f8c843845980a58ee869a99019425ec Mon Sep 17 00:00:00 2001 From: frobino Date: Fri, 10 Jul 2026 19:16:01 +0200 Subject: [PATCH 02/16] works --- Dockerfile | 15 ++++++++++ android/build.gradle | 9 ++++-- build-android.sh | 66 +++++++++++++++++++++++++++++++------------- 3 files changed, 68 insertions(+), 22 deletions(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..64f217a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +FROM mobiledevops/android-sdk-image:36.1.0 + +# Remove Java 21 (incompatible with Gradle 7.3.3), install Java 11, CMake, Ninja, Git +RUN apt-get update && \ + apt-get remove -y openjdk-21-jdk openjdk-21-jre && \ + apt-get install -y openjdk-11-jdk curl unzip git cmake ninja-build && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* && \ + update-alternatives --set java /usr/lib/jvm/java-11-openjdk-amd64/bin/java && \ + update-alternatives --set javac /usr/lib/jvm/java-11-openjdk-amd64/bin/javac + +ENV JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64 + +# Set work directory +WORKDIR /workspace \ No newline at end of file diff --git a/android/build.gradle b/android/build.gradle index 07b05eb..9a1a4c6 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -2,9 +2,10 @@ apply plugin: 'com.android.application' // Relative path to engine source code directory. Modify as required. def projectSourceDir = '..' -// Relative path to project source code directory. Modify as required. +// Relative path to engine source code directory. Modify as required. def rbfxSourceDir = '../3rdParty/rbfx' // Minimum required CMake version. This is same as in ../CMakeLists.txt. +def cmakeSdkPath = '"$projectDir/../../../rebelfork-sdk-android-clang-arm64-dll-latest"' def cmakeVersion = '3.22.0.0+' buildscript { @@ -28,12 +29,14 @@ android { minSdkVersion 17 targetSdkVersion 32 ndk { - abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86_64' + abiFilters 'arm64-v8a' } externalNativeBuild { cmake { arguments '-DANDROID_STL=c++_static', '-DANDROID_PLATFORM=android-21', '-DANDROID=1', - '-DANDROID_ARM_MODE=arm', '-DBUILD_SHARED_LIBS=OFF' + '-DANDROID_ARM_MODE=arm', '-DBUILD_SHARED_LIBS=ON', + '-DCMAKE_PREFIX_PATH=' + new File(projectDir, '../rebelfork-sdk-android-clang-arm64-dll-latest/share').absolutePath, + '-DUrho3D_DIR=' + new File(projectDir, '../rebelfork-sdk-android-clang-arm64-dll-latest/share/Urho3D/CMake').absolutePath } } } diff --git a/build-android.sh b/build-android.sh index bf7f173..3afa7b1 100755 --- a/build-android.sh +++ b/build-android.sh @@ -1,6 +1,6 @@ #!/bin/bash -# Build script for Android project using RebelFork SDK and Docker +# Build script for Android project using RebelFork SDK and custom Docker image set -e # Exit on any error @@ -20,9 +20,9 @@ rm -rf rebelfork-sdk-android* # Download RebelFork Android SDK echo "Downloading RebelFork Android SDK..." if command -v wget >/dev/null 2>&1; then - wget https://github.com/rbfx/rbfx/releases/download/latest/rebelfork-sdk-android-clang-x64-dll-latest.7z -O rebelfork-sdk-android.7z -elif command -v curl >/dev/null 2>&1; then - curl -L https://github.com/rbfx/rbfx/releases/download/latest/rebelfork-sdk-android-clang-x64-dll-latest.7z -o rebelfork-sdk-android.7z + wget https://github.com/rbfx/rbfx/releases/download/latest/rebelfork-sdk-android-clang-arm64-dll-latest.7z -O rebelfork-sdk-android.7z + elif command -v curl >/dev/null 2>&1; then + curl -L https://github.com/rbfx/rbfx/releases/download/latest/rebelfork-sdk-android-clang-arm64-dll-latest.7z -o rebelfork-sdk-android.7z else echo "Error: Neither wget nor curl is available. Please install one of them." exit 1 @@ -48,31 +48,59 @@ if ! command -v docker >/dev/null 2>&1; then exit 1 fi -# Pull the Docker image -echo "Pulling Docker image..." -docker pull mobiledevops/android-sdk-image:36.1.0 +# Pass SDK path to gradle +export SDK_PATH="${PWD}/${SDK_DIR}" -# Build using Docker -echo "Building Android project with Docker..." +# Create Gradle wrapper with the correct version +echo "Setting up Gradle wrapper..." +mkdir -p android/gradle/wrapper +cat > android/gradle/wrapper/gradle-wrapper.properties << 'EOF' +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +EOF + +# Initialize git submodules if they exist +if [ -f ".gitmodules" ]; then + echo "Initializing git submodules..." + git submodule sync + git submodule update --init --recursive +fi + +# Create 3rdParty/rbfx directory (needs rbfx source for SDL Java files) +echo "Setting up rbfx source directory..." +mkdir -p 3rdParty +if [ ! -d "3rdParty/rbfx" ]; then + echo "Cloning rbfx source repository..." + git clone --depth 1 https://github.com/rbfx/rbfx.git 3rdParty/rbfx +fi + +# Build using our custom Docker image with Gradle wrapper +echo "Building Android project with custom Docker image..." docker run --rm \ -v "$PWD:/workspace" \ -w /workspace \ - mobiledevops/android-sdk-image:36.1.0 \ + rbfx-android-builder \ bash -c " set -e echo '=== Inside Docker container ===' echo 'Current directory:' \$PWD - echo 'Listing files:' + echo 'Listing files top-level:' ls -la - # Try to build using Gradle - if [ -f 'android/gradlew' ]; then - echo 'Using Gradle wrapper...' - cd android && chmod +x gradlew && ./gradlew assembleDebug - else - echo 'Using system Gradle...' - cd android && gradle assembleDebug - fi + echo 'Checking 3rdParty/rbfx:' + ls 3rdParty/rbfx/Source/ThirdParty/SDL/android-project/app/src/main/java/ 2>/dev/null || echo 'SDL Java dir missing' + + cd android + + # Make gradlew executable + chmod +x gradlew + + # Build using Gradle wrapper (already configured with Gradle 7.3.3) + echo 'Building with Gradle wrapper (Gradle 7.3.3)...' + ./gradlew assembleDebug echo 'Build completed!' echo 'APK files found:' From 33e81402c4d92f8c077897877471295098197ada Mon Sep 17 00:00:00 2001 From: frobino Date: Sat, 11 Jul 2026 18:46:31 +0200 Subject: [PATCH 03/16] Build for x64 so that I can test locally on waydroid --- android/build.gradle | 10 +++++----- build-android.sh | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index 9a1a4c6..097c3e2 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -5,7 +5,7 @@ def projectSourceDir = '..' // Relative path to engine source code directory. Modify as required. def rbfxSourceDir = '../3rdParty/rbfx' // Minimum required CMake version. This is same as in ../CMakeLists.txt. -def cmakeSdkPath = '"$projectDir/../../../rebelfork-sdk-android-clang-arm64-dll-latest"' +def cmakeSdkPath = '"$projectDir/../../../rebelfork-sdk-android-clang-x64-dll-latest"' def cmakeVersion = '3.22.0.0+' buildscript { @@ -29,14 +29,14 @@ android { minSdkVersion 17 targetSdkVersion 32 ndk { - abiFilters 'arm64-v8a' + abiFilters 'x86_64' } externalNativeBuild { cmake { - arguments '-DANDROID_STL=c++_static', '-DANDROID_PLATFORM=android-21', '-DANDROID=1', + arguments '-DANDROID_STL=c++_shared', '-DANDROID_PLATFORM=android-21', '-DANDROID=1', '-DANDROID_ARM_MODE=arm', '-DBUILD_SHARED_LIBS=ON', - '-DCMAKE_PREFIX_PATH=' + new File(projectDir, '../rebelfork-sdk-android-clang-arm64-dll-latest/share').absolutePath, - '-DUrho3D_DIR=' + new File(projectDir, '../rebelfork-sdk-android-clang-arm64-dll-latest/share/Urho3D/CMake').absolutePath + '-DCMAKE_PREFIX_PATH=' + new File(projectDir, '../rebelfork-sdk-android-clang-x64-dll-latest/share').absolutePath, + '-DUrho3D_DIR=' + new File(projectDir, '../rebelfork-sdk-android-clang-x64-dll-latest/share/Urho3D/CMake').absolutePath } } } diff --git a/build-android.sh b/build-android.sh index 3afa7b1..40fd4cf 100755 --- a/build-android.sh +++ b/build-android.sh @@ -20,9 +20,9 @@ rm -rf rebelfork-sdk-android* # Download RebelFork Android SDK echo "Downloading RebelFork Android SDK..." if command -v wget >/dev/null 2>&1; then - wget https://github.com/rbfx/rbfx/releases/download/latest/rebelfork-sdk-android-clang-arm64-dll-latest.7z -O rebelfork-sdk-android.7z + wget https://github.com/rbfx/rbfx/releases/download/latest/rebelfork-sdk-android-clang-x64-dll-latest.7z -O rebelfork-sdk-android.7z elif command -v curl >/dev/null 2>&1; then - curl -L https://github.com/rbfx/rbfx/releases/download/latest/rebelfork-sdk-android-clang-arm64-dll-latest.7z -o rebelfork-sdk-android.7z + curl -L https://github.com/rbfx/rbfx/releases/download/latest/rebelfork-sdk-android-clang-x64-dll-latest.7z -o rebelfork-sdk-android.7z else echo "Error: Neither wget nor curl is available. Please install one of them." exit 1 @@ -116,4 +116,4 @@ else echo "WARNING: No APK files found. Check the build output above for errors." fi -echo "Build script completed." \ No newline at end of file +echo "Build script completed." From 25c207e22478479fd8026b78b944ab159eb9ded8 Mon Sep 17 00:00:00 2001 From: frobino Date: Sat, 11 Jul 2026 20:23:38 +0200 Subject: [PATCH 04/16] Decrease the size of the needed image --- Dockerfile | 26 ++++++----- build-android.sh | 115 +++++++++++++---------------------------------- 2 files changed, 45 insertions(+), 96 deletions(-) diff --git a/Dockerfile b/Dockerfile index 64f217a..174478a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,19 @@ -FROM mobiledevops/android-sdk-image:36.1.0 +FROM beigirad/tiny-android -# Remove Java 21 (incompatible with Gradle 7.3.3), install Java 11, CMake, Ninja, Git +# Minimal build tools for Android NDK/CMake builds. +# SDK download, extraction, and submodule initialization happen on the host. RUN apt-get update && \ - apt-get remove -y openjdk-21-jdk openjdk-21-jre && \ - apt-get install -y openjdk-11-jdk curl unzip git cmake ninja-build && \ + apt-get install -y --no-install-recommends \ + cmake \ + ninja-build \ + python3 && \ apt-get clean && \ - rm -rf /var/lib/apt/lists/* && \ - update-alternatives --set java /usr/lib/jvm/java-11-openjdk-amd64/bin/java && \ - update-alternatives --set javac /usr/lib/jvm/java-11-openjdk-amd64/bin/javac + rm -rf \ + /var/lib/apt/lists/* \ + /var/cache/apt/archives/* \ + /usr/share/doc \ + /usr/share/man \ + /usr/share/locale \ + /usr/share/info -ENV JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64 - -# Set work directory -WORKDIR /workspace \ No newline at end of file +WORKDIR /workspace diff --git a/build-android.sh b/build-android.sh index 40fd4cf..6c39bda 100755 --- a/build-android.sh +++ b/build-android.sh @@ -1,119 +1,64 @@ #!/bin/bash -# Build script for Android project using RebelFork SDK and custom Docker image +set -e -set -e # Exit on any error +echo "=== RebelFork Android Build ===" -echo "=== RebelFork Android Build Script ===" - -# Check if we're in the correct directory if [ ! -f "CMakeLists.txt" ] || [ ! -d "android" ]; then - echo "Error: This script must be run from the project root directory" - echo "Please navigate to the root of your sample-project directory" + echo "Error: run from project root" exit 1 fi -# Clean up any previous SDK downloads -echo "Cleaning up previous SDK files..." -rm -rf rebelfork-sdk-android* - -# Download RebelFork Android SDK -echo "Downloading RebelFork Android SDK..." -if command -v wget >/dev/null 2>&1; then - wget https://github.com/rbfx/rbfx/releases/download/latest/rebelfork-sdk-android-clang-x64-dll-latest.7z -O rebelfork-sdk-android.7z - elif command -v curl >/dev/null 2>&1; then - curl -L https://github.com/rbfx/rbfx/releases/download/latest/rebelfork-sdk-android-clang-x64-dll-latest.7z -o rebelfork-sdk-android.7z +# Download SDK only if not already extracted +SDK_DIR="rebelfork-sdk-android-clang-x64-dll-latest" +if [ ! -d "$SDK_DIR" ]; then + echo "Downloading SDK..." + rm -f rebelfork-sdk-android-clang-x64-dll-latest.7z + if command -v wget >/dev/null 2>&1; then + wget -q https://github.com/rbfx/rbfx/releases/download/latest/rebelfork-sdk-android-clang-x64-dll-latest.7z -O rebelfork-sdk-android.7z + elif command -v curl >/dev/null 2>&1; then + curl -sL https://github.com/rbfx/rbfx/releases/download/latest/rebelfork-sdk-android-clang-x64-dll-latest.7z -o rebelfork-sdk-android.7z + else + echo "Error: wget or curl required" + exit 1 + fi + echo "Extracting SDK..." + 7z x rebelfork-sdk-android.7z -o. -y > /dev/null + rm -f rebelfork-sdk-android.7z else - echo "Error: Neither wget nor curl is available. Please install one of them." - exit 1 -fi - -# Extract SDK -echo "Extracting SDK..." -7z x rebelfork-sdk-android.7z - -# Find the extracted SDK directory (name may vary) -SDK_DIR=$(find . -maxdepth 1 -type d -name "rebelfork-sdk-android*" | head -n 1) -if [ -z "$SDK_DIR" ]; then - echo "Error: Could not find extracted SDK directory" - exit 1 + echo "SDK already present, skipping download" fi -echo "Found SDK directory: $SDK_DIR" - -# Check if Docker is available +# Docker if ! command -v docker >/dev/null 2>&1; then - echo "Error: Docker is not installed or not in PATH" - echo "Please install Docker and make sure it's running" + echo "Error: docker not found" exit 1 fi -# Pass SDK path to gradle -export SDK_PATH="${PWD}/${SDK_DIR}" - -# Create Gradle wrapper with the correct version -echo "Setting up Gradle wrapper..." -mkdir -p android/gradle/wrapper -cat > android/gradle/wrapper/gradle-wrapper.properties << 'EOF' -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -EOF - -# Initialize git submodules if they exist +# Submodules if [ -f ".gitmodules" ]; then - echo "Initializing git submodules..." git submodule sync git submodule update --init --recursive fi -# Create 3rdParty/rbfx directory (needs rbfx source for SDL Java files) -echo "Setting up rbfx source directory..." -mkdir -p 3rdParty +# rbfx source for SDL Java files if [ ! -d "3rdParty/rbfx" ]; then - echo "Cloning rbfx source repository..." git clone --depth 1 https://github.com/rbfx/rbfx.git 3rdParty/rbfx fi -# Build using our custom Docker image with Gradle wrapper -echo "Building Android project with custom Docker image..." +# Build +echo "Building..." docker run --rm \ -v "$PWD:/workspace" \ -w /workspace \ - rbfx-android-builder \ + rbfx-android-builder-slim \ bash -c " set -e - echo '=== Inside Docker container ===' - echo 'Current directory:' \$PWD - echo 'Listing files top-level:' - ls -la - - echo 'Checking 3rdParty/rbfx:' - ls 3rdParty/rbfx/Source/ThirdParty/SDL/android-project/app/src/main/java/ 2>/dev/null || echo 'SDL Java dir missing' - cd android - - # Make gradlew executable chmod +x gradlew - - # Build using Gradle wrapper (already configured with Gradle 7.3.3) - echo 'Building with Gradle wrapper (Gradle 7.3.3)...' ./gradlew assembleDebug - - echo 'Build completed!' - echo 'APK files found:' - find . -name '*.apk' 2>/dev/null || echo 'No APK files found' " -# Check for the output APK -echo "=== Build Summary ===" -if find android -name "*.apk" 2>/dev/null | grep -q apk; then - echo "SUCCESS: APK files have been generated:" - find android -name "*.apk" 2>/dev/null -else - echo "WARNING: No APK files found. Check the build output above for errors." -fi - -echo "Build script completed." +# Report +echo "=== Result ===" +find android -name "*.apk" 2>/dev/null && echo "Build succeeded" || echo "No APK found" From e5256ac0c9057f9802df7d373f091836e6146141 Mon Sep 17 00:00:00 2001 From: frobino Date: Sat, 11 Jul 2026 20:46:31 +0200 Subject: [PATCH 05/16] Even tinier --- Dockerfile | 19 ++----------------- build-android.sh | 4 ++++ 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/Dockerfile b/Dockerfile index 174478a..5508a47 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,19 +1,4 @@ FROM beigirad/tiny-android - -# Minimal build tools for Android NDK/CMake builds. -# SDK download, extraction, and submodule initialization happen on the host. -RUN apt-get update && \ - apt-get install -y --no-install-recommends \ - cmake \ - ninja-build \ - python3 && \ - apt-get clean && \ - rm -rf \ - /var/lib/apt/lists/* \ - /var/cache/apt/archives/* \ - /usr/share/doc \ - /usr/share/man \ - /usr/share/locale \ - /usr/share/info - +RUN apt-get update -qq && apt-get install -y --no-install-recommends \ + cmake ninja-build && apt-get clean && rm -rf /var/lib/apt/lists/* WORKDIR /workspace diff --git a/build-android.sh b/build-android.sh index 6c39bda..1edfc28 100755 --- a/build-android.sh +++ b/build-android.sh @@ -35,6 +35,10 @@ if ! command -v docker >/dev/null 2>&1; then exit 1 fi +# Build Docker image +echo "Building Docker image..." +docker build -t rbfx-android-builder-slim . + # Submodules if [ -f ".gitmodules" ]; then git submodule sync From 8e7e2579996df36397ee438671195ff3fef74be5 Mon Sep 17 00:00:00 2001 From: frobino Date: Sat, 11 Jul 2026 21:52:02 +0200 Subject: [PATCH 06/16] Add Android build support with Gradle wrapper and fix compatibility issues --- .gitignore | 13 +- Dockerfile | 8 +- android/build.gradle | 3 +- .../gradle/wrapper/gradle-wrapper.properties | 5 + android/gradlew | 188 ++++++++++++++++++ android/gradlew.bat | 92 +++++++++ build-android.sh | 3 +- 7 files changed, 307 insertions(+), 5 deletions(-) create mode 100644 android/gradle/wrapper/gradle-wrapper.properties create mode 100755 android/gradlew create mode 100644 android/gradlew.bat diff --git a/.gitignore b/.gitignore index d1af5ef..d14af91 100644 --- a/.gitignore +++ b/.gitignore @@ -7,11 +7,22 @@ cmake-build/ .vscode/ # Android output directories -gradle* .gradle .idea android/.cxx +# But don't ignore Gradle wrapper files +!android/gradlew +!android/gradlew.bat +!android/gradle/ + # Ignore log files Urho3D.log +# Ignore SDK and 3rd party directories +rebelfork-sdk-* +3rdParty/ + +# Ignore temp files +*.jar + diff --git a/Dockerfile b/Dockerfile index 5508a47..cc21af7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,10 @@ FROM beigirad/tiny-android RUN apt-get update -qq && apt-get install -y --no-install-recommends \ - cmake ninja-build && apt-get clean && rm -rf /var/lib/apt/lists/* + cmake ninja-build openjdk-11-jdk wget unzip python3 && apt-get clean && rm -rf /var/lib/apt/lists/* +# Install Gradle 7.5 (compatible with Android Gradle plugin 7.2.1) +RUN wget -q https://services.gradle.org/distributions/gradle-7.5-bin.zip -O /tmp/gradle.zip && \ + unzip -q /tmp/gradle.zip -d /opt && \ + rm /tmp/gradle.zip +ENV GRADLE_HOME=/opt/gradle-7.5 +ENV PATH=$PATH:$GRADLE_HOME/bin WORKDIR /workspace diff --git a/android/build.gradle b/android/build.gradle index 097c3e2..d07741f 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -36,7 +36,8 @@ android { arguments '-DANDROID_STL=c++_shared', '-DANDROID_PLATFORM=android-21', '-DANDROID=1', '-DANDROID_ARM_MODE=arm', '-DBUILD_SHARED_LIBS=ON', '-DCMAKE_PREFIX_PATH=' + new File(projectDir, '../rebelfork-sdk-android-clang-x64-dll-latest/share').absolutePath, - '-DUrho3D_DIR=' + new File(projectDir, '../rebelfork-sdk-android-clang-x64-dll-latest/share/Urho3D/CMake').absolutePath + '-DUrho3D_DIR=' + new File(projectDir, '../rebelfork-sdk-android-clang-x64-dll-latest/share/Urho3D/CMake').absolutePath, + '-DPACKAGE_TOOL_EXECUTABLE=python3 ' + new File(projectDir, '../rebelfork-sdk-android-clang-x64-dll-latest/bin/PackageTool.py').absolutePath } } } diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..68d3dee --- /dev/null +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists \ No newline at end of file diff --git a/android/gradlew b/android/gradlew new file mode 100755 index 0000000..ccd95fb --- /dev/null +++ b/android/gradlew @@ -0,0 +1,188 @@ +#!/bin/sh + +############################################################################## +# +# Copyright 2015-2023 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*:/* | ?:/* ) false ;; # don't mess with paths like /foo/bar:baz or C:/foo/bar #( + //* ) false ;; # don't mess with paths like //server/foo/bar #( + *) true ;; # mess with others + esac + then + # Assume argument is a path + arg=$( cygpath --path --mixed "$arg" ) + fi + set -- "$@" "$arg" + i=$((i+1)) + shift + done +fi + + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither readarray nor <<<. +# +# On macOS this requires gnu-xargs from homebrew, +# since the default xargs implementation is broken and doesn't support -r. +exec "$JAVACMD" "$@" \ No newline at end of file diff --git a/android/gradlew.bat b/android/gradlew.bat new file mode 100644 index 0000000..0faad1a --- /dev/null +++ b/android/gradlew.bat @@ -0,0 +1,92 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega \ No newline at end of file diff --git a/build-android.sh b/build-android.sh index 1edfc28..bb1404d 100755 --- a/build-android.sh +++ b/build-android.sh @@ -59,8 +59,7 @@ docker run --rm \ bash -c " set -e cd android - chmod +x gradlew - ./gradlew assembleDebug + gradle assembleDebug " # Report From c320b28b6b08c6e8964ae212789188330ff3360f Mon Sep 17 00:00:00 2001 From: frobino Date: Thu, 16 Jul 2026 22:43:37 +0200 Subject: [PATCH 07/16] Now it uses ResourceRoot properly --- Source/Application/CMakeLists.txt | 8 ++++++-- android/assets/ResourceRoot.ini | 3 +++ 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 android/assets/ResourceRoot.ini diff --git a/Source/Application/CMakeLists.txt b/Source/Application/CMakeLists.txt index af03155..15c8519 100644 --- a/Source/Application/CMakeLists.txt +++ b/Source/Application/CMakeLists.txt @@ -1,8 +1,12 @@ # Include source files. file (GLOB_RECURSE SOURCE_FILES *.h *.cpp) -# Add dynamic or static library. -add_library (${APP_PLUGIN_NAME} ${SOURCE_FILES}) +if (ANDROID) + add_library(${APP_PLUGIN_NAME} STATIC ${SOURCE_FILES}) + target_compile_definitions(${APP_PLUGIN_NAME} PRIVATE URHO3D_STATIC=1) +else() + add_library(${APP_PLUGIN_NAME} ${SOURCE_FILES}) +endif () # Link the engine and dependencies. target_link_libraries (${APP_PLUGIN_NAME} PRIVATE diff --git a/android/assets/ResourceRoot.ini b/android/assets/ResourceRoot.ini new file mode 100644 index 0000000..6de333e --- /dev/null +++ b/android/assets/ResourceRoot.ini @@ -0,0 +1,3 @@ +CoreData=CoreData +Data=Data +Cache=Cache From 70d2f3b4c75374dd98e7a27d862aa80acda07ad8 Mon Sep 17 00:00:00 2001 From: frobino Date: Thu, 16 Jul 2026 22:46:17 +0200 Subject: [PATCH 08/16] Add gitkeep to keep empty folder --- android/assets/Cache/.gitkeep | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 android/assets/Cache/.gitkeep diff --git a/android/assets/Cache/.gitkeep b/android/assets/Cache/.gitkeep new file mode 100644 index 0000000..e69de29 From e00d12ecb476b3613bf12dc4216e5b2532e0efa4 Mon Sep 17 00:00:00 2001 From: frobino Date: Mon, 20 Jul 2026 13:37:57 +0200 Subject: [PATCH 09/16] Remove 3rdPrty workaround since latest sdk include java files --- .gitignore | 3 +-- android/assets/.gitignore | 3 ++- android/build.gradle | 4 ++-- build-android.sh | 5 ----- 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index d14af91..3d56546 100644 --- a/.gitignore +++ b/.gitignore @@ -19,9 +19,8 @@ android/.cxx # Ignore log files Urho3D.log -# Ignore SDK and 3rd party directories +# Ignore SDK directories rebelfork-sdk-* -3rdParty/ # Ignore temp files *.jar diff --git a/android/assets/.gitignore b/android/assets/.gitignore index 4e2f71c..fdc1ae7 100644 --- a/android/assets/.gitignore +++ b/android/assets/.gitignore @@ -1,3 +1,4 @@ # Ignore everything as it just contains symlinks or copied of files (Windows platform without MKLINK) * -!.gitignore \ No newline at end of file +!.gitignore +!.gitkeep \ No newline at end of file diff --git a/android/build.gradle b/android/build.gradle index d07741f..06c937f 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -3,7 +3,7 @@ apply plugin: 'com.android.application' // Relative path to engine source code directory. Modify as required. def projectSourceDir = '..' // Relative path to engine source code directory. Modify as required. -def rbfxSourceDir = '../3rdParty/rbfx' +def sdkPath = '../rebelfork-sdk-android-clang-x64-dll-latest' // Minimum required CMake version. This is same as in ../CMakeLists.txt. def cmakeSdkPath = '"$projectDir/../../../rebelfork-sdk-android-clang-x64-dll-latest"' def cmakeVersion = '3.22.0.0+' @@ -56,7 +56,7 @@ android { } sourceSets.main { manifest.srcFile 'AndroidManifest.xml' - java.srcDirs = ['src', "${rbfxSourceDir}/Source/ThirdParty/SDL/android-project/app/src/main/java"] + java.srcDirs = ['src', "${sdkPath}/share/Urho3D/Android/java"] res.srcDirs = ['res', "${projectSourceDir}/StoreArt/Android/Icons"] assets.srcDirs = ['assets', "${projectSourceDir}/Project"] } diff --git a/build-android.sh b/build-android.sh index bb1404d..b09c38b 100755 --- a/build-android.sh +++ b/build-android.sh @@ -45,11 +45,6 @@ if [ -f ".gitmodules" ]; then git submodule update --init --recursive fi -# rbfx source for SDL Java files -if [ ! -d "3rdParty/rbfx" ]; then - git clone --depth 1 https://github.com/rbfx/rbfx.git 3rdParty/rbfx -fi - # Build echo "Building..." docker run --rm \ From c4778c57d7d12be1acf8fdd0df3b74f839528f33 Mon Sep 17 00:00:00 2001 From: frobino Date: Mon, 20 Jul 2026 14:02:24 +0200 Subject: [PATCH 10/16] re-add some java files still needed --- build-android.sh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/build-android.sh b/build-android.sh index b09c38b..42c866c 100755 --- a/build-android.sh +++ b/build-android.sh @@ -29,6 +29,30 @@ else echo "SDK already present, skipping download" fi +# Patch SDK with missing SDL Java sources (not packaged in released SDK) +SDL_SRC="../rbfx/Source/ThirdParty/SDL/android-project/app/src/main/java" +SDL_DST="$SDK_DIR/share/Urho3D/Android/java" +if [ -d "$SDL_SRC" ]; then + for java_file in \ + org/libsdl/app/SDLActivity.java \ + org/libsdl/app/SDL.java \ + org/libsdl/app/SDLAudioManager.java \ + org/libsdl/app/SDLControllerManager.java \ + org/libsdl/app/HIDDevice.java \ + org/libsdl/app/HIDDeviceManager.java \ + org/libsdl/app/HIDDeviceBLESteamController.java \ + org/libsdl/app/HIDDeviceUSB.java; do + if [ ! -f "$SDK_DIR/share/Urho3D/Android/java/$java_file" ]; then + mkdir -p "$SDL_DST/$(dirname "$java_file")" + cp "$SDL_SRC/$java_file" "$SDL_DST/$java_file" + echo "Patched: $java_file" + fi + done + echo "SDL Java sources patched into SDK" +else + echo "Warning: $SDL_SRC not found, SDL Java patch skipped" +fi + # Docker if ! command -v docker >/dev/null 2>&1; then echo "Error: docker not found" From 786421d0259328ebee9886071895caff645e7fb7 Mon Sep 17 00:00:00 2001 From: frobino Date: Mon, 20 Jul 2026 14:47:35 +0200 Subject: [PATCH 11/16] Add Chace folder --- android/assets/Cache/common_cache.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 android/assets/Cache/common_cache.txt diff --git a/android/assets/Cache/common_cache.txt b/android/assets/Cache/common_cache.txt new file mode 100644 index 0000000..bb1f62c --- /dev/null +++ b/android/assets/Cache/common_cache.txt @@ -0,0 +1 @@ +When editor import files it will place assets in the Cache folder. \ No newline at end of file From 2bd60dfcd10060d8fe28da1be53686de2a306dd0 Mon Sep 17 00:00:00 2001 From: frobino Date: Tue, 28 Jul 2026 09:17:16 +0200 Subject: [PATCH 12/16] Restore build to arm, remove cp of java now packaged in sdk --- android/build.gradle | 12 ++++++------ build-android.sh | 33 ++++++--------------------------- 2 files changed, 12 insertions(+), 33 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index 06c937f..310bad2 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -3,9 +3,9 @@ apply plugin: 'com.android.application' // Relative path to engine source code directory. Modify as required. def projectSourceDir = '..' // Relative path to engine source code directory. Modify as required. -def sdkPath = '../rebelfork-sdk-android-clang-x64-dll-latest' +def sdkPath = '../rebelfork-sdk-android-clang-arm64-dll-latest' // Minimum required CMake version. This is same as in ../CMakeLists.txt. -def cmakeSdkPath = '"$projectDir/../../../rebelfork-sdk-android-clang-x64-dll-latest"' +def cmakeSdkPath = '"$projectDir/../../../rebelfork-sdk-android-clang-arm64-dll-latest"' def cmakeVersion = '3.22.0.0+' buildscript { @@ -29,15 +29,15 @@ android { minSdkVersion 17 targetSdkVersion 32 ndk { - abiFilters 'x86_64' + abiFilters 'arm64-v8a' } externalNativeBuild { cmake { arguments '-DANDROID_STL=c++_shared', '-DANDROID_PLATFORM=android-21', '-DANDROID=1', '-DANDROID_ARM_MODE=arm', '-DBUILD_SHARED_LIBS=ON', - '-DCMAKE_PREFIX_PATH=' + new File(projectDir, '../rebelfork-sdk-android-clang-x64-dll-latest/share').absolutePath, - '-DUrho3D_DIR=' + new File(projectDir, '../rebelfork-sdk-android-clang-x64-dll-latest/share/Urho3D/CMake').absolutePath, - '-DPACKAGE_TOOL_EXECUTABLE=python3 ' + new File(projectDir, '../rebelfork-sdk-android-clang-x64-dll-latest/bin/PackageTool.py').absolutePath + '-DCMAKE_PREFIX_PATH=' + new File(projectDir, '../rebelfork-sdk-android-clang-arm64-dll-latest/share').absolutePath, + '-DUrho3D_DIR=' + new File(projectDir, '../rebelfork-sdk-android-clang-arm64-dll-latest/share/Urho3D/CMake').absolutePath, + '-DPACKAGE_TOOL_EXECUTABLE=python3 ' + new File(projectDir, '../rebelfork-sdk-android-clang-arm64-dll-latest/bin/PackageTool.py').absolutePath } } } diff --git a/build-android.sh b/build-android.sh index 42c866c..4f2a751 100755 --- a/build-android.sh +++ b/build-android.sh @@ -10,14 +10,14 @@ if [ ! -f "CMakeLists.txt" ] || [ ! -d "android" ]; then fi # Download SDK only if not already extracted -SDK_DIR="rebelfork-sdk-android-clang-x64-dll-latest" +SDK_DIR="rebelfork-sdk-android-clang-arm64-dll-latest" if [ ! -d "$SDK_DIR" ]; then echo "Downloading SDK..." - rm -f rebelfork-sdk-android-clang-x64-dll-latest.7z + rm -f rebelfork-sdk-android-clang-arm64-dll-latest.7z if command -v wget >/dev/null 2>&1; then - wget -q https://github.com/rbfx/rbfx/releases/download/latest/rebelfork-sdk-android-clang-x64-dll-latest.7z -O rebelfork-sdk-android.7z + wget -q https://github.com/rbfx/rbfx/releases/download/latest/rebelfork-sdk-android-clang-arm64-dll-latest.7z -O rebelfork-sdk-android.7z elif command -v curl >/dev/null 2>&1; then - curl -sL https://github.com/rbfx/rbfx/releases/download/latest/rebelfork-sdk-android-clang-x64-dll-latest.7z -o rebelfork-sdk-android.7z + curl -sL https://github.com/rbfx/rbfx/releases/download/latest/rebelfork-sdk-android-clang-arm64-dll-latest.7z -o rebelfork-sdk-android.7z else echo "Error: wget or curl required" exit 1 @@ -29,29 +29,8 @@ else echo "SDK already present, skipping download" fi -# Patch SDK with missing SDL Java sources (not packaged in released SDK) -SDL_SRC="../rbfx/Source/ThirdParty/SDL/android-project/app/src/main/java" -SDL_DST="$SDK_DIR/share/Urho3D/Android/java" -if [ -d "$SDL_SRC" ]; then - for java_file in \ - org/libsdl/app/SDLActivity.java \ - org/libsdl/app/SDL.java \ - org/libsdl/app/SDLAudioManager.java \ - org/libsdl/app/SDLControllerManager.java \ - org/libsdl/app/HIDDevice.java \ - org/libsdl/app/HIDDeviceManager.java \ - org/libsdl/app/HIDDeviceBLESteamController.java \ - org/libsdl/app/HIDDeviceUSB.java; do - if [ ! -f "$SDK_DIR/share/Urho3D/Android/java/$java_file" ]; then - mkdir -p "$SDL_DST/$(dirname "$java_file")" - cp "$SDL_SRC/$java_file" "$SDL_DST/$java_file" - echo "Patched: $java_file" - fi - done - echo "SDL Java sources patched into SDK" -else - echo "Warning: $SDL_SRC not found, SDL Java patch skipped" -fi +# Add coredata (should this be part of the SDK?) +cp -r ../rbfx/bin/CoreData Project/ # Docker if ! command -v docker >/dev/null 2>&1; then From 785efd775f04e4a8500f5d424d59e7b41a5866df Mon Sep 17 00:00:00 2001 From: frobino Date: Tue, 28 Jul 2026 09:25:24 +0200 Subject: [PATCH 13/16] Add initial script for windows build --- build-android.ps1 | 70 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 build-android.ps1 diff --git a/build-android.ps1 b/build-android.ps1 new file mode 100644 index 0000000..a0eb280 --- /dev/null +++ b/build-android.ps1 @@ -0,0 +1,70 @@ +$ErrorActionPreference = "Stop" + +Write-Host "=== RebelFork Android Build ===" + +# Check project root directory +if (-not (Test-Path "CMakeLists.txt") -or -not (Test-Path "android")) { + Write-Error "Error: run from project root" + exit 1 +} + +# Download SDK only if not already extracted +$SdkDir = "rebelfork-sdk-android-clang-arm64-dll-latest" +if (-not (Test-Path $SdkDir)) { + Write-Host "Downloading SDK..." + if (Test-Path "rebelfork-sdk-android.7z") { Remove-Item "rebelfork-sdk-android.7z" -Force } + + $SdkUrl = "https://github.com/rbfx/rbfx/releases/download/latest/rebelfork-sdk-android-clang-arm64-dll-latest.7z" + Invoke-WebRequest -Uri $SdkUrl -OutFile "rebelfork-sdk-android.7z" + + # Check for 7-Zip installation + if (-not (Get-Command 7z -ErrorAction SilentlyContinue)) { + Write-Error "Error: 7z (7-Zip) is required and was not found in PATH" + exit 1 + } + + Write-Host "Extracting SDK..." + 7z x rebelfork-sdk-android.7z -o. -y | Out-Null + Remove-Item "rebelfork-sdk-android.7z" -Force +} else { + Write-Host "SDK already present, skipping download" +} + +# Add coredata (should this be part of the SDK?) +Copy-Item -Path "..\rbfx\bin\CoreData" -Destination "Project\" -Recurse -Force + +# Check Docker availability +if (-not (Get-Command docker -ErrorAction SilentlyContinue)) { + Write-Error "Error: docker not found" + exit 1 +} + +# Build Docker image +Write-Host "Building Docker image..." +docker build -t rbfx-android-builder-slim . + +# Submodules +if (Test-Path ".gitmodules") { + git submodule sync + git submodule update --init --recursive +} + +# Build +Write-Host "Building..." +$CurrentDir = Get-Location +docker run --rm ` + -v "${CurrentDir}:/workspace" ` + -w /workspace ` + rbfx-android-builder-slim ` + bash -c "set -e; cd android; gradle assembleDebug" + +# Report +Write-Host "=== Result ===" +$Apks = Get-ChildItem -Path "android" -Filter "*.apk" -Recurse -ErrorAction SilentlyContinue + +if ($Apks) { + $Apks | ForEach-Object { Write-Host $_.FullName } + Write-Host "Build succeeded" +} else { + Write-Host "No APK found" +} From 735df08fef117906b39e448b9bb0775cc0539146 Mon Sep 17 00:00:00 2001 From: frobino Date: Tue, 28 Jul 2026 11:57:59 +0200 Subject: [PATCH 14/16] Remove gradlew, fix permissions on android artifacts --- android/gradlew | 188 -------------------------------------------- android/gradlew.bat | 92 ---------------------- build-android.sh | 1 + 3 files changed, 1 insertion(+), 280 deletions(-) delete mode 100755 android/gradlew delete mode 100644 android/gradlew.bat diff --git a/android/gradlew b/android/gradlew deleted file mode 100755 index ccd95fb..0000000 --- a/android/gradlew +++ /dev/null @@ -1,188 +0,0 @@ -#!/bin/sh - -############################################################################## -# -# Copyright 2015-2023 the original author or authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -############################################################################## - -# Attempt to set APP_HOME - -# Resolve links: $0 may be a link -app_path=$0 - -# Need this for daisy-chained symlinks. -while - APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path - [ -h "$app_path" ] -do - ls=$( ls -ld "$app_path" ) - link=${ls#*' -> '} - case $link in #( - /*) app_path=$link ;; #( - *) app_path=$APP_HOME$link ;; - esac -done - -# This is normally unused -# shellcheck disable=SC2034 -APP_BASE_NAME=${0##*/} -# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD=maximum - -warn () { - echo "$*" -} >&2 - -die () { - echo - echo "$*" - echo - exit 1 -} >&2 - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "$( uname )" in #( - CYGWIN* ) cygwin=true ;; #( - Darwin* ) darwin=true ;; #( - MSYS* | MINGW* ) msys=true ;; #( - NONSTOP* ) nonstop=true ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD=$JAVA_HOME/jre/sh/java - else - JAVACMD=$JAVA_HOME/bin/java - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD=java - if ! command -v java >/dev/null 2>&1 - then - die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -fi - -# Increase the maximum file descriptors if we can. -if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then - case $MAX_FD in #( - max*) - # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC2039,SC3045 - MAX_FD=$( ulimit -H -n ) || - warn "Could not query maximum file descriptor limit" - esac - case $MAX_FD in #( - '' | soft) :;; #( - *) - # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC2039,SC3045 - ulimit -n "$MAX_FD" || - warn "Could not set maximum file descriptor limit to $MAX_FD" - esac -fi - -# Collect all arguments for the java command, stacking in reverse order: -# * args from the command line -# * the main class name -# * -classpath -# * -D...appname settings -# * --module-path (only if needed) -# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. - -# For Cygwin or MSYS, switch paths to Windows format before running java -if "$cygwin" || "$msys" ; then - APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) - - JAVACMD=$( cygpath --unix "$JAVACMD" ) - - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - if - case $arg in #( - -*) false ;; # don't mess with options #( - /?*:/* | ?:/* ) false ;; # don't mess with paths like /foo/bar:baz or C:/foo/bar #( - //* ) false ;; # don't mess with paths like //server/foo/bar #( - *) true ;; # mess with others - esac - then - # Assume argument is a path - arg=$( cygpath --path --mixed "$arg" ) - fi - set -- "$@" "$arg" - i=$((i+1)) - shift - done -fi - - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' - -# Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, -# and any embedded shellness will be escaped. -# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be -# treated as '${Hostname}' itself on the command line. - -set -- \ - "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ - "$@" - -# Stop when "xargs" is not available. -if ! command -v xargs >/dev/null 2>&1 -then - die "xargs is not available" -fi - -# Use "xargs" to parse quoted args. -# -# With -n1 it outputs one arg per line, with the quotes and backslashes removed. -# -# In Bash we could simply go: -# -# readarray ARGS < <( xargs -n1 <<<"$var" ) && -# set -- "${ARGS[@]}" "$@" -# -# but POSIX shell has neither readarray nor <<<. -# -# On macOS this requires gnu-xargs from homebrew, -# since the default xargs implementation is broken and doesn't support -r. -exec "$JAVACMD" "$@" \ No newline at end of file diff --git a/android/gradlew.bat b/android/gradlew.bat deleted file mode 100644 index 0faad1a..0000000 --- a/android/gradlew.bat +++ /dev/null @@ -1,92 +0,0 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%"=="" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%"=="" set DIRNAME=. -@rem This is normally unused -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if %ERRORLEVEL% equ 0 goto execute - -echo. 1>&2 -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 -echo. 1>&2 -echo Please set the JAVA_HOME variable in your environment to match the 1>&2 -echo location of your Java installation. 1>&2 - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. 1>&2 -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 -echo. 1>&2 -echo Please set the JAVA_HOME variable in your environment to match the 1>&2 -echo location of your Java installation. 1>&2 - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega \ No newline at end of file diff --git a/build-android.sh b/build-android.sh index 4f2a751..f7b85d1 100755 --- a/build-android.sh +++ b/build-android.sh @@ -58,6 +58,7 @@ docker run --rm \ set -e cd android gradle assembleDebug + chown -R $(id -u):$(id -g) /workspace " # Report From e0384bca3b053a56f2f33f6d716af3f8a165c729 Mon Sep 17 00:00:00 2001 From: frobino Date: Tue, 28 Jul 2026 12:51:26 +0200 Subject: [PATCH 15/16] Restore .git files to original state when possible --- .gitignore | 12 +----------- android/assets/.gitignore | 3 +-- android/assets/Cache/.gitkeep | 0 android/gradle/wrapper/gradle-wrapper.properties | 5 ----- 4 files changed, 2 insertions(+), 18 deletions(-) delete mode 100644 android/assets/Cache/.gitkeep delete mode 100644 android/gradle/wrapper/gradle-wrapper.properties diff --git a/.gitignore b/.gitignore index 3d56546..d1af5ef 100644 --- a/.gitignore +++ b/.gitignore @@ -7,21 +7,11 @@ cmake-build/ .vscode/ # Android output directories +gradle* .gradle .idea android/.cxx -# But don't ignore Gradle wrapper files -!android/gradlew -!android/gradlew.bat -!android/gradle/ - # Ignore log files Urho3D.log -# Ignore SDK directories -rebelfork-sdk-* - -# Ignore temp files -*.jar - diff --git a/android/assets/.gitignore b/android/assets/.gitignore index fdc1ae7..4e2f71c 100644 --- a/android/assets/.gitignore +++ b/android/assets/.gitignore @@ -1,4 +1,3 @@ # Ignore everything as it just contains symlinks or copied of files (Windows platform without MKLINK) * -!.gitignore -!.gitkeep \ No newline at end of file +!.gitignore \ No newline at end of file diff --git a/android/assets/Cache/.gitkeep b/android/assets/Cache/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index 68d3dee..0000000 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,5 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists \ No newline at end of file From eff795530c50d661a8e029ade368f7ef2426f25f Mon Sep 17 00:00:00 2001 From: frobino Date: Tue, 28 Jul 2026 13:25:00 +0200 Subject: [PATCH 16/16] Removed windows script (not fully tested) --- build-android.ps1 | 70 ----------------------------------------------- 1 file changed, 70 deletions(-) delete mode 100644 build-android.ps1 diff --git a/build-android.ps1 b/build-android.ps1 deleted file mode 100644 index a0eb280..0000000 --- a/build-android.ps1 +++ /dev/null @@ -1,70 +0,0 @@ -$ErrorActionPreference = "Stop" - -Write-Host "=== RebelFork Android Build ===" - -# Check project root directory -if (-not (Test-Path "CMakeLists.txt") -or -not (Test-Path "android")) { - Write-Error "Error: run from project root" - exit 1 -} - -# Download SDK only if not already extracted -$SdkDir = "rebelfork-sdk-android-clang-arm64-dll-latest" -if (-not (Test-Path $SdkDir)) { - Write-Host "Downloading SDK..." - if (Test-Path "rebelfork-sdk-android.7z") { Remove-Item "rebelfork-sdk-android.7z" -Force } - - $SdkUrl = "https://github.com/rbfx/rbfx/releases/download/latest/rebelfork-sdk-android-clang-arm64-dll-latest.7z" - Invoke-WebRequest -Uri $SdkUrl -OutFile "rebelfork-sdk-android.7z" - - # Check for 7-Zip installation - if (-not (Get-Command 7z -ErrorAction SilentlyContinue)) { - Write-Error "Error: 7z (7-Zip) is required and was not found in PATH" - exit 1 - } - - Write-Host "Extracting SDK..." - 7z x rebelfork-sdk-android.7z -o. -y | Out-Null - Remove-Item "rebelfork-sdk-android.7z" -Force -} else { - Write-Host "SDK already present, skipping download" -} - -# Add coredata (should this be part of the SDK?) -Copy-Item -Path "..\rbfx\bin\CoreData" -Destination "Project\" -Recurse -Force - -# Check Docker availability -if (-not (Get-Command docker -ErrorAction SilentlyContinue)) { - Write-Error "Error: docker not found" - exit 1 -} - -# Build Docker image -Write-Host "Building Docker image..." -docker build -t rbfx-android-builder-slim . - -# Submodules -if (Test-Path ".gitmodules") { - git submodule sync - git submodule update --init --recursive -} - -# Build -Write-Host "Building..." -$CurrentDir = Get-Location -docker run --rm ` - -v "${CurrentDir}:/workspace" ` - -w /workspace ` - rbfx-android-builder-slim ` - bash -c "set -e; cd android; gradle assembleDebug" - -# Report -Write-Host "=== Result ===" -$Apks = Get-ChildItem -Path "android" -Filter "*.apk" -Recurse -ErrorAction SilentlyContinue - -if ($Apks) { - $Apks | ForEach-Object { Write-Host $_.FullName } - Write-Host "Build succeeded" -} else { - Write-Host "No APK found" -}