Using the Built-in RAD Studio Java Libraries for Android
Go Up to Using Java Libraries in Your RAD Studio Android Apps
The RAD Studio installation includes a set of Java libraries that are required by FireMonkey as a whole or by certain components and platform services of FireMonkey. RAD Studio also provides one or more Delphi units and C++ header files for each one of those Java libraries. You can include those Delphi or C++ files in your RAD Studio applications to access the API of the underlying Java libraries.
The RAD Studio installation also includes a classes.dex
file, which is the result of converting this set of Java libraries into a single Dalvik Executable file. RAD Studio includes the classes.dex
file in your applications by default when you deploy your applications for the Android target platform. This file allows your RAD Studio applications to interact with the Android API and the rest of the built-in RAD Studio Java libraries at run time.
RAD Studio supports importing Android libraries (.aar
files). The 'rclasser' command-line application generates an R.jar
file containing all R
Java classes needed for imported Android libraries to access Android resources through their identifier. This allows the use of external libraries like Facebook SDK for Android or Firebase Analytics.
Contents
List of Built-in RAD Studio Java Libraries for Android
The RAD Studio installation includes the following Java libraries:
Library | Native Files | Description |
---|---|---|
|
API of the Android platform. | |
|
Set of libraries that provide a wide array of different features for Android programming. | |
|
Library that provides the core functionality required by the Firebase Android Support on the Android platform. | |
|
Library that provides the core functionality required by the FireMonkey Application Platform on the Android platform. | |
|
SDK of the Google Mobile Ads service. | |
|
SDK of the Google Analytics service. | |
|
License Verification Library, a collection of helper classes to simplify adding licensing to an Android application. | |
|
API of the Google Play In-app Billing service. | |
|
API of the Google Play services. | |
|
SDK for hosting Android APK expansion files on the Google Play servers. | |
|
SDK of the Google Cloud Messaging service. |
The FireMonkey Java library is an Embarcadero library. The APK Expansion and Cloud Messaging Java libraries are third-party libraries that include modifications by Embarcadero. The rest of the Java libraries listed in the table above are unmodified third-party libraries.
The files in the Native Files column are the files that you can include in your RAD Studio applications to access the APIs of these Java libraries from your native code. You can find these files in the following paths within the RAD Studio installation folder (C:\Program Files (x86)\Embarcadero\Studio\23.0
):
- Delphi units:
source\rtl\android
(.pas
file extension) - C++ header files:
include\android\rtl
(.hpp
file extension)
Some of the features of the third-party Java libraries may require:
- Adding Uses Permissions to your Android applications.
- Customizing the
AndroidManifest.xml
file of your Android application.
Check the official documentation of each third-party library for more information.
Disabling Unnecessary Built-in RAD Studio Java Libraries to Decrease the Size of Your Application
By default, the classes.dex
file of any Android application created using RAD Studio includes all the Java libraries listed in the table above. While this ensures that your application always works, it also increases the size of your application package.
If you know for sure that your application does not use some of these built-in Java libraries, such as those for advertising or analytics, you can remove those unnecessary libraries from your project so that they are not included in your application package anymore. You can always add them back later if you need them as your application provides new features.
To remove a built-in Java library from your project:
- On the Projects Window, expand the Libraries node within Target Platforms > Android.
- Right-click the Java library file that you do not want to include in the
classes.dex
file of your application. - Select Disable to disable the selected Java library file.
To enable a previously-disabled built-in library, repeat these steps but select Enable instead of Disable.
Updating Built-in RAD Studio Java Libraries
The built-in Java libraries can be changed as part of a new RAD Studio version.
The existing project files need to be updated to use the built-in Java libraries recommended for the RAD Studio version you have installed, otherwise, the generated Android application may experience unexpected issues.
Follow the steps below to get an existing project file ready to use in a new RAD Studio version:
- Go to the Projects Window.
- Select Android 32-bit or Android 64-bit as the active target platform.
- Right-click on the Libraries node.
- Click on the Revert System Files to Default menu item.
See Also
Samples
- FireMonkey Device Info sample