|
| 1 | +# 16 KB Page Size Support |
| 2 | + |
| 3 | +This Android PDF Viewer library has been updated to support 16 KB page sizes, which is required for Google Play compatibility starting November 1st, 2025. |
| 4 | + |
| 5 | +## What Changed |
| 6 | + |
| 7 | +### Build Configuration Updates |
| 8 | + |
| 9 | +1. **Android Gradle Plugin**: Already using AGP 8.13.0 (✅ above required 8.5.1) |
| 10 | +2. **NDK Version**: Updated to use NDK r28+ for 16 KB support |
| 11 | +3. **Packaging Options**: Configured to use uncompressed shared libraries for proper 16 KB alignment |
| 12 | +4. **Gradle Properties**: Added configuration for 16 KB compatibility |
| 13 | + |
| 14 | +### Key Changes Made |
| 15 | + |
| 16 | +#### android-pdf-viewer/build.gradle |
| 17 | +```gradle |
| 18 | +// 16 KB page size support configuration |
| 19 | +packagingOptions { |
| 20 | + jniLibs { |
| 21 | + useLegacyPackaging false // Use uncompressed shared libraries for 16 KB alignment |
| 22 | + } |
| 23 | +} |
| 24 | +
|
| 25 | +// Enable 16 KB page size support for native libraries |
| 26 | +ndkVersion "28.0.12433566" // Use NDK r28+ for 16 KB support |
| 27 | +``` |
| 28 | + |
| 29 | +#### sample/build.gradle |
| 30 | +```gradle |
| 31 | +packagingOptions { |
| 32 | + // ... existing exclusions ... |
| 33 | + |
| 34 | + // 16 KB page size support configuration |
| 35 | + jniLibs { |
| 36 | + useLegacyPackaging false // Use uncompressed shared libraries for 16 KB alignment |
| 37 | + } |
| 38 | +} |
| 39 | +
|
| 40 | +// Enable 16 KB page size support for native libraries |
| 41 | +ndkVersion "28.0.12433566" // Use NDK r28+ for 16 KB support |
| 42 | +``` |
| 43 | + |
| 44 | +#### gradle.properties |
| 45 | +```properties |
| 46 | +# 16 KB page size support |
| 47 | +android.bundle.enableUncompressedNativeLibs=false |
| 48 | +android.enableR8.fullMode=true |
| 49 | +``` |
| 50 | + |
| 51 | +## Native Dependencies |
| 52 | + |
| 53 | +This library uses `pdfium-android:1.9.0`, which contains native libraries. The configuration ensures these libraries are properly aligned for 16 KB page sizes. |
| 54 | + |
| 55 | +## Verification |
| 56 | + |
| 57 | +### Using the Provided Scripts |
| 58 | + |
| 59 | +#### Linux/macOS |
| 60 | +```bash |
| 61 | +./check_16kb_alignment.sh sample/build/outputs/apk/debug/sample-debug.apk |
| 62 | +``` |
| 63 | + |
| 64 | +#### Windows PowerShell |
| 65 | +```powershell |
| 66 | +.\check_16kb_alignment.ps1 -ApkFile "sample\build\outputs\apk\debug\sample-debug.apk" |
| 67 | +``` |
| 68 | + |
| 69 | +#### Windows Batch Script |
| 70 | +```batch |
| 71 | +.\realign_apk.bat "sample\build\outputs\apk\debug\sample-debug.apk" |
| 72 | +``` |
| 73 | + |
| 74 | +#### Python Script (Cross-platform) |
| 75 | +```bash |
| 76 | +python fix_16kb_alignment.py "sample/build/outputs/apk/debug/sample-debug.apk" |
| 77 | +``` |
| 78 | + |
| 79 | +### Manual Verification |
| 80 | + |
| 81 | +1. **Check APK alignment**: |
| 82 | + ```bash |
| 83 | + zipalign -c -p -v 4 your-app.apk |
| 84 | + ``` |
| 85 | + |
| 86 | +2. **Test on 16 KB device**: |
| 87 | + ```bash |
| 88 | + adb shell getconf PAGE_SIZE |
| 89 | + # Should return 16384 |
| 90 | + ``` |
| 91 | + |
| 92 | +### Fixing Alignment Issues |
| 93 | + |
| 94 | +If your APK fails 16 KB alignment checks, use the provided realignment scripts: |
| 95 | + |
| 96 | +1. **Copy your APK** to avoid file lock issues: |
| 97 | + ```bash |
| 98 | + cp sample/build/outputs/apk/debug/sample-debug.apk sample-debug-copy.apk |
| 99 | + ``` |
| 100 | + |
| 101 | +2. **Run the realignment script**: |
| 102 | + ```bash |
| 103 | + .\realign_apk.bat "sample-debug-copy.apk" |
| 104 | + ``` |
| 105 | + |
| 106 | +3. **Verify the fix**: |
| 107 | + ```bash |
| 108 | + zipalign -c -p -v 4 sample-debug-copy.apk |
| 109 | + ``` |
| 110 | + |
| 111 | +## Testing on 16 KB Devices |
| 112 | + |
| 113 | +### Android Emulator |
| 114 | +1. Download Android 15 system image with 16 KB page size support |
| 115 | +2. Create virtual device with the 16 KB system image |
| 116 | +3. Test your app on the emulator |
| 117 | + |
| 118 | +### Physical Devices |
| 119 | +- Pixel 8 and 8 Pro (Android 15 QPR1+) |
| 120 | +- Pixel 8a (Android 15 QPR1+) |
| 121 | +- Pixel 9, 9 Pro, and 9 Pro XL (Android 15 QPR2 Beta 2+) |
| 122 | + |
| 123 | +Enable "Boot with 16KB page size" in Developer Options. |
| 124 | + |
| 125 | +## Benefits |
| 126 | + |
| 127 | +Devices with 16 KB page sizes provide: |
| 128 | +- 3.16% lower app launch times on average |
| 129 | +- 4.56% reduction in power draw during app launch |
| 130 | +- 4.48% faster camera launch (hot starts) |
| 131 | +- 6.60% faster camera launch (cold starts) |
| 132 | +- 8% improved system boot time |
| 133 | + |
| 134 | +## Compatibility |
| 135 | + |
| 136 | +- ✅ **AGP Version**: 8.13.0 (above required 8.5.1) |
| 137 | +- ✅ **NDK Version**: r28+ (16 KB aligned by default) |
| 138 | +- ✅ **Native Libraries**: Configured for 16 KB alignment |
| 139 | +- ✅ **Packaging**: Uncompressed shared libraries for proper alignment |
| 140 | + |
| 141 | +## Resources |
| 142 | + |
| 143 | +- [Android 16 KB Page Size Guide](https://developer.android.com/guide/practices/page-sizes) |
| 144 | +- [Google Play 16 KB Requirement](https://android-developers.googleblog.com/2025/05/prepare-play-apps-for-devices-with-16kb-page-size.html) |
| 145 | +- [APK Analyzer Tool](https://developer.android.com/studio/build/analyze-apk) |
| 146 | + |
| 147 | +## Troubleshooting |
| 148 | + |
| 149 | +If you encounter issues: |
| 150 | + |
| 151 | +1. **Verify NDK version**: Ensure you're using NDK r28 or higher |
| 152 | +2. **Check AGP version**: Must be 8.5.1 or higher |
| 153 | +3. **Run alignment check**: Use the provided scripts to verify APK alignment |
| 154 | +4. **Test on 16 KB device**: Use emulator or physical device with 16 KB support |
| 155 | + |
| 156 | +## Support |
| 157 | + |
| 158 | +For issues related to 16 KB page size support, please check: |
| 159 | +1. The alignment verification scripts |
| 160 | +2. Android Studio's APK Analyzer |
| 161 | +3. The official Android documentation linked above |
0 commit comments