Preparing an Android Application for Deployment

From RAD Studio
Jump to: navigation, search

Go Up to Android Mobile Application Development


Your Android app is deployed when you run it on an Android target device. You can also use the Deployment Manager to manage the deployed files. After your Android application is ready for final deployment, you can proceed to build and sign your application. See Deploying Your Signed Android Application.

Configuring the Options for Deploying Your Android App

You must configure several options for your Android app before you build the application for distribution. The properties that you configure are bundled with your application, in the AndroidManifest.xml file. You cannot modify these properties after you build and sign your application. Because these properties provide key information about your application, you should ensure that they contain the correct values before you deploy your application, or you might have to rebuild your application in order to change the configured values.

Before each release of your Android application, you should check that every setting is properly configured.

To configure your Android app:

  • On the Project > Options > Application page, provide the icons and images to represent your application.
  • On the Project > Options > Version Info page, increase the version code of your application. Application stores such as Google Play may require that newer versions of your application always have a higher version code than previous versions.
  • On the Project > Options > Uses Permissions page, define the permissions that your application requires to work.
  • If you wish, you can declare some features as optional.
  • On the Project > Options > Provisioning page, select in Target the build configuration that you want to use to deploy your application (for example, Release) and provide a KeyStore file if you have not already created one. This step is necessary in order to install your application in a device that has USB debugging disabled and to distribute your application to others. For more information about keystore files, see: http://docs.oracle.com/javase/1.5.0/docs/api/java/security/KeyStore.html.

Customizing Your AndroidManifest.xml File

RAD Studio writes the options of your Android application to a special Android file, AndroidManifest.xml, which is included in your final Android package when you deploy your application for Android. This file defines things such as the version code or display name of your application, the list of permissions that your application requires, and so on.

Usually, you do not need to touch this file, and you can let RAD Studio take care of everything for you. However, RAD Studio allows you to customize the content of the AndroidManifest.xml file if you need to include custom data in this file that you can not define visually in your project options.

When you build an application for the Android target platform for the first time, RAD Studio adds a file to your project folder: AndroidManifest.template.xml. Whenever you build your application for Android, RAD Studio reads this file, replaces some placeholders in the file with actual values from your project options, and writes the resulting content into an output file: Android\<build configuration>\AndroidManifest.xml. This output file is the AndroidManifest.xml file that is included in the Android package that RAD Studio generates when you deploy your application for the Android target platform.

To customize the output AndroidManifest.xml file of a single project, edit the content of AndroidManifest.template.xml.

The AndroidManifest.template.xml file that RAD Studio adds to a project when you build that project for the Android target platform for the first time comes from C:\Users\<username>\AppData\Roaming\Embarcadero\BDS\18.0\AndroidManifest.xml. If you want your new projects to have a different starting AndroidManifest.template.xml file, edit this file.

Re-creating the AndroidManifest.template.xml File

The AndroidManifest.template.xml file that RAD Studio generates can change between versions. To deploy a project that was build with a different version of RAD Studio, be specially careful with the existing AndroidManifest.template.xml file from your project folder.

There are two possible scenarios:

  • You want to keep the old AndroidManifest.template.xml file because it is customized.
  • You do not need to keep the old AndroidManifest.template.xml file.

Keeping the AndroidManifest.template.xml File

You might want to keep your AndroidManifest.template.xml file if you manually did modifications to the file. In this case you need to follow these steps:

  • Open your project folder.
  • Be sure to back up your AndroidManifest.template.xml file.
  • Delete the AndroidManifest.template.xml file from the project folder.
  • Open your project with the new RAD Studio version.
  • Select Android target.
  • Build the project.
    Note: Building the project creates a new AndroidManifest.template.xml file.
  • Go to your project folder to check that there is a new AndroidManifest.template.xml file.
  • Manually add your changes to the new AndroidManifest.template.xml file.

Creating a New AndroidManifest.template.xml File

If you did not modify the AndroidManifest.template.xml file, follow these steps to let that RAD Studio creates a new file:

  • Open your project folder.
  • Delete the AndroidManifest.template.xml file, if it exists.
  • Open your project with the new RAD Studio version.
  • Select Android target.
  • Build the project.
    Note: Building the project creates a new AndroidManifest.template.xml file.
  • Go to your project folder to check that there is a new AndroidManifest.template.xml file.

Declaring Features as Optional

When you build your Android application, a list of required features is automatically created based on the declared permissions. This list is informational only and does not prevent an application from installing on a device. Some services, such as Google Play, use this list to filter applications that are visible to users. This way users can see and download only those applications that are compatible with their device. All the features that your application needs are declared as required by default, which makes your application incompatible with devices that do not support those features.

If your application does not require a certain feature to function (but needs that feature for some non-essential functionality), you can declare that feature as optional. To declare a feature as optional, you must explicitly specify that feature as not-required in the application manifest.

For example, to declare that your application optionally requires access to the microphone, you need to do the following:

  • Ensure that the Record audio permission is set in Uses Permissions.
  • Manually add the following line to the the AndroidManifest.template.xml after <%uses-permission%>: (see Customizing Your AndroidManifest.xml File section for information on how to modify AndroidManifest.template.xml):
    <uses-feature android:name="android.hardware.microphone" android:required="False"/>
    
    Note: Some permissions, such as android.permission.CAMERA, imply multiple feature requirements. Read Permissions that Imply Feature Requirements for more information.

See Features Reference for a complete list of hardware and software features supported by the most current platform release.

See Also