Skip to content

Commit b8aefac

Browse files
Copilotwcchung
andcommitted
Add Android 16 KB page size support for Android 15+ compatibility
Co-authored-by: wcchung <[email protected]>
1 parent 608721e commit b8aefac

File tree

6 files changed

+158
-2
lines changed

6 files changed

+158
-2
lines changed

ANDROID_16KB_SUPPORT.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Android 16 KB Page Size Support
2+
3+
This document describes the changes made to support 16 KB memory page sizes required for Android 15+ compatibility.
4+
5+
## Background
6+
7+
Google Play requires all apps targeting Android 15+ (SDK 35+) to support 16 KB memory page sizes. This ensures compatibility with devices that use 16 KB memory pages instead of the traditional 4 KB pages for improved performance.
8+
9+
## Changes Made
10+
11+
### 1. Gradle Properties (`android/gradle.properties`)
12+
- Added `android.enablePageSizeSupport=true` to enable 16 KB page size support
13+
- Increased JVM heap size from 1536m to 2048m for better memory handling
14+
- Added `android.enableR8.fullMode=true` for additional optimizations
15+
16+
### 2. App Build Configuration (`android/app/build.gradle`)
17+
- Added NDK configuration with explicit ABI filters to ensure proper native library alignment
18+
- Added packaging options to disable legacy packaging for proper 16 KB alignment
19+
- Enhanced debug build type configuration
20+
21+
### 3. Build Tools
22+
- Confirmed Android Gradle Plugin 8.9.1 is used (supports 16 KB page sizes)
23+
24+
## Verification
25+
26+
To verify that the app supports 16 KB page sizes:
27+
28+
1. **Build the app:**
29+
```bash
30+
cd android
31+
./gradlew assembleRelease
32+
```
33+
34+
2. **Test on 16 KB devices:**
35+
- Use Android emulator with 16 KB page size configuration
36+
- Test on physical devices with 16 KB page sizes
37+
- Use Google Play Console's app bundle explorer to verify 16 KB support
38+
39+
3. **Check build output:**
40+
- Ensure no errors related to memory alignment
41+
- Verify all native libraries are properly packaged
42+
43+
## Google Play Console Verification
44+
45+
After building and uploading the app bundle to Google Play Console:
46+
1. Go to Release management > App bundle explorer
47+
2. Select the latest app bundle
48+
3. Check if "16 KB page size support" is listed as supported
49+
50+
## Testing Recommendations
51+
52+
- Test the app on devices/emulators with 16 KB page sizes
53+
- Verify all camera functionality works correctly
54+
- Test media capture and storage operations
55+
- Ensure all Capacitor plugins function properly
56+
57+
## References
58+
59+
- [Supporting 16 KB devices](https://developer.android.com/guide/practices/page-sizes#build)
60+
- [Prepare your Play app for 16 KB page sizes](https://www.youtube.com/watch?v=MnMGJhuChRI)
61+
- [Technical requirement announcement](https://android-developers.googleblog.com/2025/05/prepare-play-apps-for-devices-with-16kb-page-size.html)

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,18 @@ The script does the same thing for you.
147147
npm run build.android
148148
```
149149

150+
#### Android 16 KB Page Size Support
151+
152+
This app supports 16 KB memory page sizes as required by Google Play for Android 15+ compatibility. The configuration is automatically enabled in the build system.
153+
154+
To verify 16 KB page size support:
155+
156+
```bash
157+
./verify-16kb-support.sh
158+
```
159+
160+
For detailed information about the 16 KB page size implementation, see [`ANDROID_16KB_SUPPORT.md`](./ANDROID_16KB_SUPPORT.md).
161+
150162
### Caveat
151163

152164
- This app is still in the experimental stage.

android/app/build.gradle

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ android {
1010
versionCode 1032
1111
versionName "0.103.2"
1212
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
13+
14+
// Support for 16 KB page sizes (Android 15+ requirement)
15+
// This ensures compatibility with devices using 16 KB memory pages
16+
ndk {
17+
// Ensure native libraries are built with 16 KB page alignment
18+
abiFilters 'arm64-v8a', 'armeabi-v7a', 'x86', 'x86_64'
19+
}
1320
}
1421
buildFeatures {
1522
dataBinding true
@@ -19,6 +26,18 @@ android {
1926
minifyEnabled false
2027
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
2128
}
29+
debug {
30+
// Enable debugging and ensure 16 KB page size compatibility
31+
debuggable true
32+
}
33+
}
34+
35+
// Configure packaging options for 16 KB page size compatibility
36+
packagingOptions {
37+
// Ensure native libraries are properly aligned for 16 KB page sizes
38+
jniLibs {
39+
useLegacyPackaging = false
40+
}
2241
}
2342
}
2443

android/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ buildscript {
77
mavenCentral()
88
}
99
dependencies {
10+
// Android Gradle Plugin 8.9.1 supports 16 KB page sizes (Android 15+ requirement)
1011
classpath 'com.android.tools.build:gradle:8.9.1'
1112
classpath 'com.google.gms:google-services:4.4.2'
1213

android/gradle.properties

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99

1010
# Specifies the JVM arguments used for the daemon process.
1111
# The setting is particularly useful for tweaking memory settings.
12-
org.gradle.jvmargs=-Xmx1536m
12+
# Increased memory allocation for 16 KB page size compatibility
13+
org.gradle.jvmargs=-Xmx2048m
1314

1415
# When configured, Gradle will run in incubating parallel mode.
1516
# This option should only be used with decoupled projects. More details, visit
@@ -19,4 +20,11 @@ org.gradle.jvmargs=-Xmx1536m
1920
# AndroidX package structure to make it clearer which packages are bundled with the
2021
# Android operating system, and which are packaged with your app's APK
2122
# https://developer.android.com/topic/libraries/support-library/androidx-rn
22-
android.useAndroidX=true
23+
android.useAndroidX=true
24+
25+
# Enable 16 KB page size support for Android 15+ compatibility
26+
# This ensures the app can run on devices with 16 KB memory page sizes
27+
android.enablePageSizeSupport=true
28+
29+
# Additional optimizations for memory handling
30+
android.enableR8.fullMode=true

verify-16kb-support.sh

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/bin/bash
2+
3+
# Build verification script for 16 KB page size support
4+
# This script helps verify that the Android build configuration supports 16 KB page sizes
5+
6+
echo "🔧 Verifying Android 16 KB page size support..."
7+
8+
# Check if we're in the right directory
9+
if [ ! -f "android/build.gradle" ]; then
10+
echo "❌ Error: This script must be run from the project root directory"
11+
exit 1
12+
fi
13+
14+
echo "📋 Checking build configuration..."
15+
16+
# Check gradle.properties
17+
if grep -q "android.enablePageSizeSupport=true" android/gradle.properties; then
18+
echo "✅ Page size support enabled in gradle.properties"
19+
else
20+
echo "❌ Page size support not found in gradle.properties"
21+
exit 1
22+
fi
23+
24+
# Check Android Gradle Plugin version
25+
if grep -q "com.android.tools.build:gradle:8\.[7-9]" android/build.gradle; then
26+
echo "✅ Android Gradle Plugin version supports 16 KB page sizes"
27+
else
28+
echo "⚠️ Warning: Android Gradle Plugin version may not support 16 KB page sizes"
29+
fi
30+
31+
# Check NDK configuration
32+
if grep -q "abiFilters.*arm64-v8a" android/app/build.gradle; then
33+
echo "✅ NDK configuration includes ARM64 support"
34+
else
35+
echo "❌ NDK configuration missing or incomplete"
36+
exit 1
37+
fi
38+
39+
# Check packaging options
40+
if grep -q "useLegacyPackaging = false" android/app/build.gradle; then
41+
echo "✅ Modern packaging enabled for proper alignment"
42+
else
43+
echo "❌ Legacy packaging configuration missing"
44+
exit 1
45+
fi
46+
47+
echo ""
48+
echo "🎉 All 16 KB page size support configurations are in place!"
49+
echo ""
50+
echo "Next steps:"
51+
echo "1. Build the app: cd android && ./gradlew assembleRelease"
52+
echo "2. Test on 16 KB page size devices/emulators"
53+
echo "3. Upload to Google Play Console and verify 16 KB support in bundle explorer"
54+
echo ""
55+
echo "For more information, see ANDROID_16KB_SUPPORT.md"

0 commit comments

Comments
 (0)