If, for whatever reason, you want to set up the Android SDK/NDK (perhaps there was a failure during your Delphi install), the manual process can be a little involved. This article lays out the steps which includes using an AndroidSDKInstaller app that makes life a little easier.

In Case You Missed It

RAD Studio 10.4.1 has been released recently! I may do my own post about what is included, however I recommend checking the blog roll on the right hand side of this page, as well as your own favourite blogs and newsfeeds.

Jim McKeeth’s Android SDK/NDK article

Last year, Jim McKeeth wrote this excellent article which describes how to install the SDK/NDK manually, so you may wish to read that first, however there’s some manual steps that can be done via the command line that I’ve automated in the installer.

Install the JDK

As per Jim’s article,  the first step is to install a JDK. You will need to install it in order for the AndroidSDKInstaller app to work, if you are going to use it. You can choose the AdoptOpenJDK, or you can still install the JDK from Oracle – please use the Windows installer for your system (x86 if 32-bit only, or x64 if 64-bit) at the bottom of the Java SE Development Kit section.

Using AndroidSDKInstaller

Once the JDK has been installed, you can use the AndroidSDKInstaller that has been built to ease the process of installing the Android SDK tools, build-tools and platforms. The installer has been purpose-built to provide the minimum required to use with Delphi.

When running the installer, click the Download button to download the SDK tools. I recommend creating a folder dedicated to where the SDK and NDK will end up being installed. In this example, I’ve created a folder called Android, and a subfolder called SDK where the SDK tools will be downloaded to, and also where the build-tools and platforms will be installed:

Once you’ve selected the SDK folder, the installer will then download and extract the SDK tools, and retrieve the packages available for install. The Select SDK button can be used in the case where you have an existing SDK, and just want to install extra build-tools and/or platforms.

Once the installer has retrieved the lists of packages, it will then look like this:

As can be seen, Platform Tools is checked by default – Delphi requires these in order to function. You have a choice of Build Tools and Platforms that you can install, however it is recommended just to install those that will work with your installed version of Delphi. In Delphi 10.4.x, I recommend using build-tools version 29.0.2, and platform android-29. Once you have selected the build-tools and platform, click the Install button:

The installer will inform you when it has finished. Click OK, then click Close

Installing the NDK

As per Jim’s article, the latest NDK can be downloaded from here, however it is recommended that you use a version that is known to work. In the case of Delphi 10.4, NDK version r21b is known to work. Older versions such as this one can be downloaded from here.

Following on from the example above, I recommend extracting the NDK to a folder called NDK, at the same level as the SDK:

Adding the SDK/NDK in Delphi

For this step, I’ll refer back to Jim’s original article, rather than just repeating it. Please see the section “Setting Up The IDE SDK Manager”, remembering where you installed the SDK/NDK as per the instructions above.

Important information about the NDK settings

If, like me, you happen to be targeting devices including those that have older versions of Android (some of them have Android 4.4!), you will need to make a couple of tweaks to the NDK settings. These are:

  • NDK API Location
  • C++ Builder NDK Library Path (not essential if you are not using C++ Builder, however included here for completeness)
  • Delphi NDK Library Path

As per the following screenshot, I have changed the platform level for each of these settings to android-19. This is the lowest API level supported by the native code in the resulting Delphi application, and corresponds to Android 4.4:

A complete list of released Android versions and their API levels can be found here.

Conclusion

That should cover all of the steps. If I’ve missed anything, please let me know in the comments. Hopefully the AndroidSDKInstaller app makes this process a lot easier for you!