Categories
Android

Manually Installing Android SDK, NDK, and Java for FireMonkey Development

10.3 Rio’s installer (I use and recommend the EXE/web over the ISO, since it is faster and more flexible) does a fantastic job of installing and setting everything up for Android development, without requiring any manual steps. Still, sometimes it is nice to be able to manually install everything, which brings me to this guide.

I’m a big believer in understanding the way the underlying systems work, and installing this way is more work, but you are able to see how everything works together. Also, this allows you to share SDKs between multiple installations, and also place the tools like ADB on your path for easy use. Not to say you can’t do all of that with the automatic install, but sometimes it is nice to get your hands dirty.

I also occasionally run into people who are having trouble getting things installed for various reasons. So this is a great way to troubleshoot installation issues.

This assumes you already have RAD Studio, Delphi, or C++Builder 10.3 Rio already installed. 10.3 Rio changed the versions of the SDK and NDK that it uses, so this guide won’t work with other versions. Also, I switched to AdoptOpenJDK instead of the traditional Oracle JDK. I’ll show you how to install that here, but if you use a different JDK that will be different for you.

What is the OpenJDK?

OpenJDK is a free and open-source implementation of the Java Platform, Standard Edition. It is the result of an effort Sun Microsystems began in 2006. The implementation is licensed under the GNU General Public License version 2 with a linking exception. It is the official reference implementation of Java SE since version 7.

There are multiple builds available, with different terms and support options. Why not just use the Java SE JDK? Oracle has changed the license on it that may require you to purchase a license to use it. For my purposes it is better save than sorry, plus the OpenJDK is a lot smaller and less annoying. I picked AdoptOpenJDK, which seems to be the most popular option, but this should mostly work the same with any build.

AdoptOpenJDK includes the JRE (Java Runtime Environment) too, so just one install. You must install it first because you can’t run the Android SDK manager without Java installed, and the IDE users the JDK for KeyTool and JarSigner.

AdoptOpenJDK Install Instructions

Download the Windows installer for OpenJDK 8 (LTS). I used the 64-bit Windows version with the HotSpot JVM, and then just run the installation. Be sure to tell it to set the JAVA_HOME environment variable.

While installing AdoptOpenJDK, have it Set JAVA_HOME environment variable.

Installing the Android SDK

When you visit the site to download the Android SDK they try to get you to download the full Android Studio, but you don’t need all of that. If you scroll to the bottom, you will see the “Command line tools only” downloads. One note, the downloads listed on the site no longer include the GUI SDK Manager. If you scroll down further, I’ll show you how you can download that and use it instead.

Command-Line Only install

  • sdk-tools-windows-4333796.zip
  • Windows Platform SDK
  • 148 MB (156,136,858 bytes)
  • SHA256 7e81d69c303e47a4f0e748a6352d85cd0c8fd90a5a95ae4e076b5e5f960d3c7a

This isn’t an installer, so just pick a folder to unzip it into. You will just find a “tools” folder in the zip. This contains the SDK Manager to install the rest of the Android SDK. I typically unzip it into the folder:

C:\Users\Public\Documents\Embarcadero\Studio\AndroidSDK\

Then use the sdkmanager command-line tool (in the tools\bin folder) to install everything you need. Notice I am installing the Android 26 Platform. This is the version you want to use with 10.3 Rio. It meets the new Target SDK requirements and still gives your Android apps maximum compatibility. This is the version 10.3 Rio is designed to work with.

sdkmanager "build-tools;29.0.0" "extras;google;usb_driver" "platforms;android-26" "tools" "platform-tools" 

Android SDK with GUI Install

For some reason the Android SDK GUI Installer isn’t listed for download, but the file is still available on their servers.

The fact we are installing an older version of the SDK isn’t a big deal because we will still update it when we are done, but now we have a choice of using the command-line interface like I showed in the previous section, or using the GUI SDK Manager by running the Android.bat file in the tools folder.

Once you run the SDK manager, you want to install the latest Android SDK Tools, Android SDK Platform-tools, Android SDK Build-tools, Android API 26 SDK Platform, and the Google USB Driver. It will default to installing a lot of other things you don’t need. Feel free to deselect those. The Google USB Driver isn’t technically needed, but is nice to have.

The GUI for the Android SDK Manager

Once you’ve selected what you want installed, you can always update them via the command line with the sdkmanager utility in the tools\bin folder

sdkmanager --update

Installing the Android NDK

10.3 Rio updated the version of the Android NDK it uses to release 17b. It was the latest at the time of Rio’s development. There have been some new NDK releases since then. If you visit the Older Releases page for the Android NDK you will see 17b isn’t listed there, but the download file is still available. 17c may work, but I haven’t tested it extensively yet.

The NDK is also a zip file, so just extract it to the folder of your choosing. I’ll extract it next to my Android SDK. The root folder in the zip file is “android-ndk-r17b”

C:\Users\Public\Documents\Embarcadero\Studio\android-ndk-r17b 

There are no further installation steps necessary. Your folders should look something like this when you are done:

The folder containing the Android SDK and NDK

I’ve expanded the directories so you can see the build tools and Android platforms also installed

Environment Variables and System Path

Last thing you need to do is set up some Environment Variables and add things to your system path. This isn’t strictly necessary, but I highly recommend it!

Make sure your JAVA_HOME is correct, and set the ANDROID_HOME environment variable.

Then add the following to your system path

  • %JAVA_HOME%\bin (you can replace the expanded version with this)
  • %JAVA_HOME%\jre\bin
  • %ANDROID_HOME%\tools
  • %ANDROID_HOME%\tools\bin
  • %ANDROID_HOME%\platform-tools
The first JAVA path is the JRE, the second is the JDK.
Using the environment variables in the path saves environment space.

Settings Up the IDE SDK Manager

Since we’ve installed the SDK manually, we need to tell the IDE where to find it. This is really simple. Go into Tools ? Options ? Deployment ? SDK Manager (or just use the IDE search for SDK Manager) and add a new SDK entry.

If you have an existing Android entry here, you can remove it before adding a new one.
We are adding a new Android platform.
Provide the three paths based on where you installed them

The next stage in the wizard looks to make sure it can find everything it needs. If you didn’t install everything with the Android SDK Manager, then you may see a warning symbol next to something. If that is the case go back and double check the installation.

Be sure you select Android-26 for the API level, especially if you installed other versions too.
The SDK Manager found everything it needs to continue.

And with that you are ready to develop and deploy Android apps with FireMonkey.

2 replies on “Manually Installing Android SDK, NDK, and Java for FireMonkey Development”

Comments are closed.