Running Your Android Application on an Android Emulator
RAD Studio provides a default Android emulator for your use. The emulator is named rsxe5_android.exe, and it is located in C:\Users\<username>\.android\avd\
.
You can either use the default rsxe5_android emulator or create an Android emulator yourself.
The default Android emulator is created by a script that cannot add one critical property -- GPU emulation. You should add this property to the rsxe5_android.exe emulator, as described below in #To Add GPU Emulation to the Default Emulator.
Before you run your application on your Android emulator, start your Android emulator as described below in #To Start Your Android Emulator, so as to reduce startup time when you run your Android application from the IDE.
- The default installed location of the Android development tools is:
C:\Users\Public\Documents\RAD Studio\12.0\PlatformSDKs\adt-bundle-windows-x86-20130522\sdk\tools
- The default installed location of the Android development tools is:
To Add GPU Emulation to the Default Emulator
The default emulator (rsxe5_android) does not have the Use Host GPU property set by default. You might find that the emulator runs faster if you enable GPU emulation, as follows:
- Open the Android Virtual Device Manager: Select Start > All Programs > Embarcadero RAD Studio > Android SDKs > Android AVD Manager:
- Select the rsxe5_android emulator and click the Edit button.
- Note: If the rsxe5_android emulator is not present, you can create your own Android emulator. See Creating an Android Emulator.
- On the Edit Android Virtual Device (AVD) dialog box, click New in the Hardware field.
- Add (select) the GPU emulation property in the list of emulator properties, and click OK:
- Set the value of the GPU emulation property to yes:
- Click Edit AVD to save your changes.
To Start Your Android Emulator
- Start the Android Virtual Device Manager: Select Start > All Programs > Embarcadero RAD Studio > Android SDKs > Android AVD Manager.
- In the Android Virtual Device Manager, select your Android emulator in the list and click Start.
- On the Launch options dialog box, click Launch:
To Run Your Application on Your Android Emulator
- Open your Android application in RAD Studio.
- In the Project Manager, enable the emulator as the target platform.
- If necessary, expand the Target Platforms node and double-click the Android target platform. (The active target platform is displayed using a bold font.)
- Expand the Android node in the Project Manager.
- Expand the child Target node.
- Double-click the target Android emulator to activate it. (The active emulator is displayed using a bold font.)
- Note: If the emulator is not shown, right-click the Target node and select Refresh. If the emulator still is not displayed, see Using the Target Node.
- In the following image you can see the default rsxe5_android emulator running, and the target platform setting activated in the Project Manager:
-
- In the device selector in the FireMonkey Mobile Form Designer, select the device that matches the emulator you are using. For example:
- If you are using the default rsxe5_android emulator with its built-in skin, select WXGA800.
- If your emulator uses the WQVGA400 device, select 3.3" WQVGA Android Phone (240dp x 400 dp)
- Run your application:
- Run with debugging (Run > Run or
F9
) - Run without debugging (Run > Run Without Debugging or
Shift+Ctrl+F9
)
- Run with debugging (Run > Run or
- Compile and deploy messages should appear in the IDE.
- If the emulator is not running, the IDE displays: "The selected emulator is not running. Do you want start it?" Click Yes. A "Launching emulator" message is displayed.
- Open your emulator screen and watch for the app to appear.
- In the following image you can see a custom Nexus 4 emulator running a simple Hello World! application:
-
RAD Studio builds your application for Android and runs your application on the selected Android emulator. If the active Android emulator is not running, RAD Studio shows a dialog box that gives you the choice to start your Android emulator. If your Android emulator screen is locked, unlock it to access your application.
Android emulators run much slower than real devices due to the ARM platform emulation on top of a non-ARM system; if performance prevents you from using an Android emulator side by side with RAD Studio, see Running and Debugging Your Android Application Remotely. For obvious reasons, emulators also lack some of the features that real devices provide, although you can emulate some of those features such as geo location.