Skip to content

Commit dc2c83c

Browse files
authored
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)
1 parent c5edf4b commit dc2c83c

File tree

8 files changed

+28
-4
lines changed

8 files changed

+28
-4
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ jobs:
562562
run: |
563563
python build-scripts/build-release.py \
564564
--actions android \
565-
--android-api 23 \
565+
--android-api 21 \
566566
--android-ndk-home "${{ steps.setup-ndk.outputs.ndk-path }}" \
567567
--commit ${{ inputs.commit }} \
568568
--root "${{ steps.tar.outputs.path }}" \

Android.mk

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ LOCAL_LDLIBS := -ldl -lGLESv1_CM -lGLESv2 -lOpenSLES -llog -landroid
108108

109109
LOCAL_LDFLAGS := -Wl,--no-undefined -Wl,--no-undefined-version -Wl,--version-script=$(LOCAL_PATH)/src/dynapi/SDL_dynapi.sym
110110

111+
# https://developer.android.com/guide/practices/page-sizes
112+
LOCAL_LDFLAGS += "-Wl,-z,max-page-size=16384"
113+
LOCAL_LDFLAGS += "-Wl,-z,common-page-size=16384"
114+
111115
ifeq ($(NDK_DEBUG),1)
112116
cmd-strip :=
113117
endif

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1509,6 +1509,11 @@ if(ANDROID)
15091509
endif()
15101510
endif()
15111511

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

android-project/app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ android {
1919
abiFilters 'arm64-v8a'
2020
}
2121
cmake {
22-
arguments "-DANDROID_PLATFORM=android-21", "-DANDROID_STL=c++_static"
22+
arguments "-DANDROID_PLATFORM=android-21", "-DANDROID_STL=c++_static", "-DAPP_SUPPORT_FLEXIBLE_PAGE_SIZES=true"
2323
// abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
2424
abiFilters 'arm64-v8a'
2525
}

android-project/app/jni/Application.mk

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,7 @@
77
APP_ABI := armeabi-v7a arm64-v8a x86 x86_64
88

99
# Min runtime API level
10-
APP_PLATFORM=android-16
10+
APP_PLATFORM=android-21
11+
12+
# https://developer.android.com/guide/practices/page-sizes#update-packaging
13+
APP_SUPPORT_FLEXIBLE_PAGE_SIZES := true

android-project/app/jni/src/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,9 @@ endif()
2626
add_library(main SHARED
2727
YourSourceHere.c
2828
)
29+
30+
#https://developer.android.com/guide/practices/page-sizes#update-packaging
31+
target_link_options(main PRIVATE "-Wl,-z,max-page-size=16384")
32+
target_link_options(main PRIVATE "-Wl,-z,common-page-size=16384")
33+
2934
target_link_libraries(main PRIVATE SDL3::SDL3)

build-scripts/androidbuildlibs.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ abi="arm64-v8a" # "armeabi-v7a arm64-v8a x86 x86_64"
3030
obj=
3131
lib=
3232
ndk_args=
33+
flexpage=true
3334

3435
# Allow an external caller to specify locations and platform.
3536
while [ $# -gt 0 ]; do
@@ -42,6 +43,8 @@ while [ $# -gt 0 ]; do
4243
platform=${arg#APP_PLATFORM=}
4344
elif [ "${arg:0:8}" == "APP_ABI=" ]; then
4445
abi=${arg#APP_ABI=}
46+
elif [ "${arg:0:32}" == "APP_SUPPORT_FLEXIBLE_PAGE_SIZES=" ]; then
47+
flexpage=${arg#APP_SUPPORT_FLEXIBLE_PAGE_SIZES=}
4548
else
4649
ndk_args="$ndk_args $arg"
4750
fi
@@ -67,6 +70,9 @@ done
6770
# APP_* variables set in the environment here will not be seen by the
6871
# ndk-build makefile segments that use them, e.g., default-application.mk.
6972
# For consistency, pass all values on the command line.
73+
#
74+
# Add support for Google Play 16 KB Page size requirement:
75+
# https://developer.android.com/guide/practices/page-sizes#ndk-build
7076
ndk-build \
7177
NDK_PROJECT_PATH=null \
7278
NDK_OUT=$obj \
@@ -75,4 +81,5 @@ ndk-build \
7581
APP_ABI="$abi" \
7682
APP_PLATFORM="$platform" \
7783
APP_MODULES="SDL3" \
84+
APP_SUPPORT_FLEXIBLE_PAGE_SIZES="$flexpage" \
7885
$ndk_args

src/camera/android/SDL_camera_android.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,7 @@ static void ANDROIDCAMERA_Deinitialize(void)
814814
static bool ANDROIDCAMERA_Init(SDL_CameraDriverImpl *impl)
815815
{
816816
// !!! FIXME: slide this off into a subroutine
817-
// system libraries are in android-24 and later; we currently target android-16 and later, so check if they exist at runtime.
817+
// system libraries are in android-24 and later; we currently target android-21 and later, so check if they exist at runtime.
818818
void *libcamera2 = dlopen("libcamera2ndk.so", RTLD_NOW | RTLD_LOCAL);
819819
if (!libcamera2) {
820820
SDL_Log("CAMERA: libcamera2ndk.so can't be loaded: %s", dlerror());

0 commit comments

Comments
 (0)