Support Google Play 16 KB Page Size Requirement (#13470)

- See: https://developer.android.com/guide/practices/page-sizes#update-packaging
- Also, make min API uniform at 21 (from 16 and 23 in a few places)
This commit is contained in:
Matthew Zavislak
2025-07-31 16:12:54 -07:00
committed by GitHub
parent c5edf4bd5b
commit dc2c83c383
8 changed files with 28 additions and 4 deletions

View File

@@ -562,7 +562,7 @@ jobs:
run: | run: |
python build-scripts/build-release.py \ python build-scripts/build-release.py \
--actions android \ --actions android \
--android-api 23 \ --android-api 21 \
--android-ndk-home "${{ steps.setup-ndk.outputs.ndk-path }}" \ --android-ndk-home "${{ steps.setup-ndk.outputs.ndk-path }}" \
--commit ${{ inputs.commit }} \ --commit ${{ inputs.commit }} \
--root "${{ steps.tar.outputs.path }}" \ --root "${{ steps.tar.outputs.path }}" \

View File

@@ -108,6 +108,10 @@ LOCAL_LDLIBS := -ldl -lGLESv1_CM -lGLESv2 -lOpenSLES -llog -landroid
LOCAL_LDFLAGS := -Wl,--no-undefined -Wl,--no-undefined-version -Wl,--version-script=$(LOCAL_PATH)/src/dynapi/SDL_dynapi.sym LOCAL_LDFLAGS := -Wl,--no-undefined -Wl,--no-undefined-version -Wl,--version-script=$(LOCAL_PATH)/src/dynapi/SDL_dynapi.sym
# https://developer.android.com/guide/practices/page-sizes
LOCAL_LDFLAGS += "-Wl,-z,max-page-size=16384"
LOCAL_LDFLAGS += "-Wl,-z,common-page-size=16384"
ifeq ($(NDK_DEBUG),1) ifeq ($(NDK_DEBUG),1)
cmd-strip := cmd-strip :=
endif endif

View File

@@ -1509,6 +1509,11 @@ if(ANDROID)
endif() endif()
endif() endif()
if(TARGET SDL3-shared)
target_link_options(SDL3-shared PRIVATE "-Wl,-z,max-page-size=16384")
target_link_options(SDL3-shared PRIVATE "-Wl,-z,common-page-size=16384")
endif()
elseif(EMSCRIPTEN) elseif(EMSCRIPTEN)
# Hide noisy warnings that intend to aid mostly during initial stages of porting a new # Hide noisy warnings that intend to aid mostly during initial stages of porting a new
# project. Uncomment at will for verbose cross-compiling -I/../ path info. # project. Uncomment at will for verbose cross-compiling -I/../ path info.

View File

@@ -19,7 +19,7 @@ android {
abiFilters 'arm64-v8a' abiFilters 'arm64-v8a'
} }
cmake { cmake {
arguments "-DANDROID_PLATFORM=android-21", "-DANDROID_STL=c++_static" arguments "-DANDROID_PLATFORM=android-21", "-DANDROID_STL=c++_static", "-DAPP_SUPPORT_FLEXIBLE_PAGE_SIZES=true"
// abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64' // abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
abiFilters 'arm64-v8a' abiFilters 'arm64-v8a'
} }

View File

@@ -7,4 +7,7 @@
APP_ABI := armeabi-v7a arm64-v8a x86 x86_64 APP_ABI := armeabi-v7a arm64-v8a x86 x86_64
# Min runtime API level # Min runtime API level
APP_PLATFORM=android-16 APP_PLATFORM=android-21
# https://developer.android.com/guide/practices/page-sizes#update-packaging
APP_SUPPORT_FLEXIBLE_PAGE_SIZES := true

View File

@@ -26,4 +26,9 @@ endif()
add_library(main SHARED add_library(main SHARED
YourSourceHere.c YourSourceHere.c
) )
#https://developer.android.com/guide/practices/page-sizes#update-packaging
target_link_options(main PRIVATE "-Wl,-z,max-page-size=16384")
target_link_options(main PRIVATE "-Wl,-z,common-page-size=16384")
target_link_libraries(main PRIVATE SDL3::SDL3) target_link_libraries(main PRIVATE SDL3::SDL3)

View File

@@ -30,6 +30,7 @@ abi="arm64-v8a" # "armeabi-v7a arm64-v8a x86 x86_64"
obj= obj=
lib= lib=
ndk_args= ndk_args=
flexpage=true
# Allow an external caller to specify locations and platform. # Allow an external caller to specify locations and platform.
while [ $# -gt 0 ]; do while [ $# -gt 0 ]; do
@@ -42,6 +43,8 @@ while [ $# -gt 0 ]; do
platform=${arg#APP_PLATFORM=} platform=${arg#APP_PLATFORM=}
elif [ "${arg:0:8}" == "APP_ABI=" ]; then elif [ "${arg:0:8}" == "APP_ABI=" ]; then
abi=${arg#APP_ABI=} abi=${arg#APP_ABI=}
elif [ "${arg:0:32}" == "APP_SUPPORT_FLEXIBLE_PAGE_SIZES=" ]; then
flexpage=${arg#APP_SUPPORT_FLEXIBLE_PAGE_SIZES=}
else else
ndk_args="$ndk_args $arg" ndk_args="$ndk_args $arg"
fi fi
@@ -67,6 +70,9 @@ done
# APP_* variables set in the environment here will not be seen by the # APP_* variables set in the environment here will not be seen by the
# ndk-build makefile segments that use them, e.g., default-application.mk. # ndk-build makefile segments that use them, e.g., default-application.mk.
# For consistency, pass all values on the command line. # For consistency, pass all values on the command line.
#
# Add support for Google Play 16 KB Page size requirement:
# https://developer.android.com/guide/practices/page-sizes#ndk-build
ndk-build \ ndk-build \
NDK_PROJECT_PATH=null \ NDK_PROJECT_PATH=null \
NDK_OUT=$obj \ NDK_OUT=$obj \
@@ -75,4 +81,5 @@ ndk-build \
APP_ABI="$abi" \ APP_ABI="$abi" \
APP_PLATFORM="$platform" \ APP_PLATFORM="$platform" \
APP_MODULES="SDL3" \ APP_MODULES="SDL3" \
APP_SUPPORT_FLEXIBLE_PAGE_SIZES="$flexpage" \
$ndk_args $ndk_args

View File

@@ -814,7 +814,7 @@ static void ANDROIDCAMERA_Deinitialize(void)
static bool ANDROIDCAMERA_Init(SDL_CameraDriverImpl *impl) static bool ANDROIDCAMERA_Init(SDL_CameraDriverImpl *impl)
{ {
// !!! FIXME: slide this off into a subroutine // !!! FIXME: slide this off into a subroutine
// system libraries are in android-24 and later; we currently target android-16 and later, so check if they exist at runtime. // system libraries are in android-24 and later; we currently target android-21 and later, so check if they exist at runtime.
void *libcamera2 = dlopen("libcamera2ndk.so", RTLD_NOW | RTLD_LOCAL); void *libcamera2 = dlopen("libcamera2ndk.so", RTLD_NOW | RTLD_LOCAL);
if (!libcamera2) { if (!libcamera2) {
SDL_Log("CAMERA: libcamera2ndk.so can't be loaded: %s", dlerror()); SDL_Log("CAMERA: libcamera2ndk.so can't be loaded: %s", dlerror());