Fix missing-assets detection race, 16 KB page alignment, and Android audio backend
build / build (push) Successful in 2m11s
build / build (push) Successful in 2m11s
- QuestShockActivity now actually blocks the native engine from starting when game data is missing, closing three gaps found via on-device testing: super.onCreate() must run unconditionally first (Android throws SuperNotCalledException otherwise); SDLActivity.mBrokenLibraries is now set provisionally before the storage-permission check, since onWindowFocusChanged() closing the permission dialog could otherwise start the engine before the async onRequestPermissionsResult() callback ran; and a new GameSurface (SDLSurface subclass) closes the actual gap that let the init_popups NULL-deref crash through even with mBrokenLibraries set - SDLSurface.surfaceChanged() starts the native thread directly without ever checking that flag. - Force Android to use SDL2's openslES audio backend instead of AAudio (android/engine-patches/05-android-audio-driver.patch): AAudio only allows one open playback device at a time, but the engine opens two (cutscene audio via SDL_OpenAudioDevice, SFX/MIDI via Mix_OpenAudio), hitting an assertion failure on real hardware. - Add 16 KB ELF page-size alignment (-Wl,-z,max-page-size=16384) to every Android shared library - the four prebuilts (SDL2, SDL2_mixer, fluidsynth-lite, gl4es, in build-image/Dockerfile) and the engine's own libmain.so (build.gradle) - matching Google's Play Store requirement for Android 15+ and clearing Android Studio's compatibility warning. - Add a stageEngine Gradle task that automatically re-stages the patched engine/ copy and prebuilt libraries before any Android Studio build (hooked into preBuild, with proper up-to-date checking), so source/ patch changes can't silently go stale in the build/android-engine scratch copy - previously a manual, easy-to-forget step. Skips automatically inside the build-image container so make apk/CI are unaffected.
This commit is contained in:
@@ -46,6 +46,13 @@ ARG ANDROID_COMPILE_SDK_VERSION=34
|
||||
ARG ANDROID_BUILD_TOOLS_VERSION=34.0.0
|
||||
ARG ANDROID_NDK_VERSION=26.1.10909125
|
||||
ARG ANDROID_CMAKE_VERSION=3.22.1
|
||||
# NDK 26 doesn't yet default to 16 KB-aligned ELF LOAD segments (that only
|
||||
# became automatic in NDK 28+) - Google requires this for Play Store
|
||||
# submissions targeting Android 15+ as of Nov 2025, and it's cheap/harmless
|
||||
# to do regardless of Play Store status. Passed to every Android shared-lib
|
||||
# CMake configure below, and to the engine's own build via
|
||||
# android/app/build.gradle's externalNativeBuild.cmake.arguments.
|
||||
ARG ANDROID_16KB_LDFLAGS="-Wl,-z,max-page-size=16384"
|
||||
# GL4ES (https://github.com/ptitSeb/gl4es) - translates the engine's
|
||||
# desktop-style immediate-mode OpenGL calls into real GLES/EGL calls, so
|
||||
# engine/src/MacSrc/OpenGL.cc needs no immediate-mode rewrite on Android.
|
||||
@@ -182,6 +189,7 @@ RUN curl -sSLO "https://www.libsdl.org/release/SDL2-${ANDROID_SDL2_VERSION}.tar.
|
||||
-DANDROID_ABI="${ANDROID_ABI}" -DANDROID_PLATFORM="android-${ANDROID_PLATFORM_VERSION}" \
|
||||
-DCMAKE_INSTALL_PREFIX=/opt/prebuilt/android/sdl2 -DBUILD_SHARED_LIBS=ON \
|
||||
-DSDL_STATIC=OFF \
|
||||
-DCMAKE_SHARED_LINKER_FLAGS="${ANDROID_16KB_LDFLAGS}" \
|
||||
&& cmake --build build-sdl2-android -j"$(nproc)" \
|
||||
&& cmake --install build-sdl2-android \
|
||||
&& rm -rf "SDL2-${ANDROID_SDL2_VERSION}" "SDL2-${ANDROID_SDL2_VERSION}.tar.gz" build-sdl2-android
|
||||
@@ -207,6 +215,7 @@ RUN curl -sSLO "https://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-${A
|
||||
-DSDL2MIXER_FLAC=OFF -DSDL2MIXER_GME=OFF -DSDL2MIXER_MOD=OFF \
|
||||
-DSDL2MIXER_MP3=OFF -DSDL2MIXER_MIDI=OFF -DSDL2MIXER_OPUS=OFF -DSDL2MIXER_VORBIS=OFF \
|
||||
-DSDL2MIXER_WAVPACK=OFF \
|
||||
-DCMAKE_SHARED_LINKER_FLAGS="${ANDROID_16KB_LDFLAGS}" \
|
||||
&& cmake --build build-sdl2mixer-android -j"$(nproc)" \
|
||||
&& cmake --install build-sdl2mixer-android \
|
||||
&& rm -rf "SDL2_mixer-${ANDROID_SDL2_MIXER_VERSION}" "SDL2_mixer-${ANDROID_SDL2_MIXER_VERSION}.tar.gz" build-sdl2mixer-android
|
||||
@@ -222,6 +231,7 @@ RUN git clone https://github.com/EtherTyper/fluidsynth-lite.git fluidsynth-lite-
|
||||
&& cmake -S fluidsynth-lite-android -B build-fluidsynth-android \
|
||||
-DCMAKE_TOOLCHAIN_FILE="${ANDROID_NDK_TOOLCHAIN}" \
|
||||
-DANDROID_ABI="${ANDROID_ABI}" -DANDROID_PLATFORM="android-${ANDROID_PLATFORM_VERSION}" \
|
||||
-DCMAKE_SHARED_LINKER_FLAGS="${ANDROID_16KB_LDFLAGS}" \
|
||||
&& cmake --build build-fluidsynth-android -j"$(nproc)" \
|
||||
&& mkdir -p /opt/prebuilt/android/fluidsynth-lite/lib /opt/prebuilt/android/fluidsynth-lite/include \
|
||||
&& cp -a build-fluidsynth-android/src/libfluidsynth.so* /opt/prebuilt/android/fluidsynth-lite/lib/ \
|
||||
@@ -254,6 +264,7 @@ RUN git clone --branch "v${ANDROID_GL4ES_VERSION}" --depth 1 \
|
||||
-DCMAKE_TOOLCHAIN_FILE="${ANDROID_NDK_TOOLCHAIN}" \
|
||||
-DANDROID_ABI="${ANDROID_ABI}" -DANDROID_PLATFORM="android-${ANDROID_PLATFORM_VERSION}" \
|
||||
-DANDROID=ON -DUSE_ANDROID_LOG=ON -DSTATICLIB=OFF \
|
||||
-DCMAKE_SHARED_LINKER_FLAGS="${ANDROID_16KB_LDFLAGS}" \
|
||||
&& cmake --build build-gl4es-android -j"$(nproc)" \
|
||||
&& mkdir -p /opt/prebuilt/android/gl4es/lib /opt/prebuilt/android/gl4es/include \
|
||||
&& cp -a gl4es-android/lib/libGL.so.1 /opt/prebuilt/android/gl4es/lib/libGL.so \
|
||||
|
||||
Reference in New Issue
Block a user