Back in May, Google announced that "16 KB page size compatibility" would become a requirement for all new and existing apps, by November 1st.
Some of you may have recieved an email from the Google Play Store recently indicating that one or more of your NativePHP apps need to be upgraded to support 16 KB page sizes.
This is because NativePHP for Mobile runs native code (not just Java/Kotlin) — PHP, which is written in C. Up until last week, our Android builds were not compiled for 16 KB support.
What does this mean? What do you need to do?
#WTF is 16 KB page size compatibility?
We're not going to get too technical here, but it's basically about how devices manage memory.
Newer devices are getting more and more memory and, to optimize the use of that memory, the system (the OS, CPU and other microcontrollers in the phone) uses a mechanism called "paging" that breaks memory segments into manageable chunks.
Bigger chunks = fewer chunks, which is generally better when you have a lot of available memory.
#Why does it matter?
If these "pages" are too small, the CPU is going to end up doing too much work looking for chunks of memory, which means more power consumption.
Bigger pages means less work, which results in better performance and lower power consumption, at the cost of using a bit more memory.
Apps that aren't compiled for the 16 KB page size will most likely experience bugs and crashes on 16 KB optimized devices.
#Why is this only an Android issue?
Firstly, Apple has been using 16 KB page sizes since the first iPhone.
By contrast, Android adopted a 4 KB page size to begin with. This meant wide support across the toolchain and allowed Android to work with more devices sooner.
Thanks to this, it has supported a wide range of devices at various price points, which is great for consumers!
But this has led to a very fragmented ecosystem of devices with a wide range of capabilities and configurations, which is painful for developers.
Many lower-end devices don't support 16 KB page sizes, but as newer devices with more memory continue to increase in market share, it makes sense to shift towards this new normal, which is what the Android team is doing with this change, as this will improve performance and battery life for the majority of users.
#Will 16 KB apps run on 4 KB devices?
4 KB devices can't be "upgraded" to support 16 KB page sizes.
But Google has gone to some lengths to ensure that apps that are 16 KB compatible will support 4 KB devices for the foreseeable future too. When you build a signed app bundle (aka AAB), it creates a "universal" binary that ensures compatibility across both types of architecture.
And the Play Store knows how to deliver the right version of your app for the user's device.
16 KB support landed in Android 15, and as the number of devices adopting 16 KB support increases towards a majority, eventually it may not make sense to support 4 KB page sizes at all any more. At this point, the Android team could decide to drop 4 KB support altogether and then older devices won't be able to get app updates.
This is likely to be a few more years away though, certainly no sooner than Android 14 going out of active support.
#What do you need to do?
If you're building your apps with NativePHP: nothing! Well, except to upgrade the nativephp/mobile
package if you're running a version below v1.8.0
.
As of Mobile version 1.8.0, NativePHP is fully 16 KB compatible.
So as long as your apps are only using native code that has been compiled for 16 KB page size support, then you won't need to do anything more than:
composer update php artisan native:install --force
And you're done! Simple.
Remember: after November 1st, you will not be able to submit app builds to the Play Store that aren't 16 KB compatible. So if you plan to make a release after that date, make sure you've upgraded to the latest version of NativePHP.
We're proud to be able to bring this level of support to NativePHP, and to have it done in plenty of time.
It really higlights the power of using NativePHP, because it frees you up as the developer to focus on building your app, not worrying about a labyrinth of dependencies and conflicts — just a couple of simple commands and you're back to work!
— Simon