In this post, we’ll show you the main features of the just released RAD Studio 10.3.3 the Delphi language support for the Android 64-bit platform.
Table of Contents
Android 64-bit Delphi Support
Platform support is provided by a new Delphi compiler for the Android 64-bit platform, which, like the Android 32-bit counterpart, is based on the LLVM compiler infrastructure (and the iOS compilers). This compiler continues to use the ARC memory model in order to reduce the migration effort required by Google for store submissions. The IDE allows you to add the new platform to an existing project, compile and debug it, and then deploy it to the store (more on this later).
All of the libraries we support on Android are available, from RTL to FireMonkey, form database access with FireDAC to Parallel Programming Library, so your code should migrate fairly smoothly. There is also support for InterBase 2020 (just released) on Android 64-bit.
Android 64-Bit Caveats
There are a few hurdles to consider when you start building Android 64-bit applications The biggest issue is that about 50% of Android devices out there have a 32-bit CPU, or they have 64-bit CPU but run a 32-bit version of the OS, and therefore cannot run 64-bit Android applications.
If you want to verify your Android device CPU can run 64-bit apps one option is to use existing apps on the Play Store, like the following:
If it indicates your CPU has 64-bit ARMv8-A instruction set, but it is set in 32-bit mode, it implies the Android version is not 64-bit. In case of a mismatch, at the moment you’ll get a specific error message when running a 64-bit APK, but a not-co-clear error message when you try to debug.
Notice also that adding new 64-bit platform doesn’t automatically add all deployment files and additional Java libraries, these might needs some fine tuning as part of the project migration. You can also consider creating a new project file (dproj) from scratch with all the correct defaults.
64-Bit Code Migration is Generally Smooth
In most cases, your Delphi code will just recompile on 64-bit platforms, and you can a larger address space — one you’d likely never use on your phone.
What is different in practice is that pointers, object references, string references and any other data type referring to a memory location becomes a 64-bit, 8 bytes pointer. This also implies that SizeOf (Integer) is now different from SizeOf (Pointer). In fact, Integers remain 4 bytes while the NativeInt type depends on the platform (4 or 8 bytes on 32-bit and 64-bit, respectively).
If you are doing any pointer math or have code that depends on data structure alignment, you might have to change it. And the same if you are type casting Integers to pointers. If you are doing low level calls to native libraries, you might also need to adjust the code.
Android App Bundle Support
The other relevant feature that Delphi 10.3.3 is introducing for Android developers is the support for the AAB format (Android App Bundle). This is a deployment file format capable of bundling both 32 and 64 binaries and files, aimed to store submission — you cannot install a bundle on your phone directly. Similarly to Apple Universal format, once you upload a bundle the end user downloading via the Play Store will just receives the proper files for the specific device (and its bitness).
To enable App Bundlesupport, you can use the matching compiler option for the 64-bit Android target:
You’ll also need to provide proper provisioning information and you can generate this from the IDE, the .aab file to upload to Google Play Store.