Sunday, 3 November 2013

My first Android App with Delphi XE5

A lot has been going on since Embarcadero released Delphi XE4. I must say I was astonished with what they achieved in such a short time with that version. Just being able to develop your own mobile applications using Delphi was something amazing. Even though I found that version quite cumbersome as it was not trivial the way to deploy your app into an iOS system I gave it a try with no much success (I needed a virtual machine for the Mac device and had to borrow someone's iPad to publish the app, but I'm not a Mac person). So, what I was really waiting for was their latest release Delphi XE5 with Android compatibility. The most interesting part: how simple it is to create a project and deploy it into your android device. In less than a minute you can have your "hello world!" app in your phone with just few clicks. 
Delphi XE5 comes with the Android SDK 22.0.1 32 bit (at least the one that I got when installing Delphi) and you can see all the configuration paths for that particular SDK under Tools -> SDK Manager:

The first step is to enable your device to accept USB Debugging. To achieve this, you can follow the steps from the following link which related the way you have to enable developer mode for Samsung Galaxy Note 3. I have got a Samsung Galaxy Mega, so the same rule applies:

Once done, you will see new options in your phone:

Enable "Still awake" and "USB debugging". Once those are enabled, plug your phone into the computer using the USB cable. Then, the phone will ask you if you want to allow USB debugging: Accept it and let's go to Delphi UI.

Now in Delphi XE5, I will create a very simple project. So, go to File -> New -> FireMonkey Mobile Application.

As my new device is not in the list of available devices, I just choose something that more or less has the same dimensions. In this case as my phablet is a 6.3 inches, I choose the WSVGA 7" option:

Once this is done, I just want to create a simple "hello world" app which consists of displaying a label and when a button is pressed displaying a message. A very simple application but without changing the way I think (I'm building a Delphi application).
unit Unit1;


  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
  FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.StdCtrls;

  TForm1 = class(TForm)
    Label1: TLabel;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
    { Private declarations }
    { Public declarations }

  Form1: TForm1;


{$R *.fmx}

procedure TForm1.Button1Click(Sender: TObject);
  showMessage('Delphi XE5 Rocks');

As you can see, I'm coding in Delphi. Once this is done, If I have followed the previous steps correctly, my phone should appear under targets for that particular SDK:
Now I just need to Save my project and Run it so it can be automatically deployed in my phone. Once done, I'll be able to see the app in my phone and perform the operations it was designed to do:
Here it is. As you can see really simple steps and with a great outcome: A Delphi App in your most loved android device. Now it's time to explore and do some more research about what you can do here.

Related links:


  1. How large was the deployed app?

  2. Is the cpu and battery usage still absurdly high for a simple hello world app?

    1. Well the CPU and battery seems reasonably OK. it takes few seconds to load up the app but apart from that it seems quite responsive. I have been playing with timers and sensors (moving and object tilting the phone) and the results are quite good.


  3. really use native controls delphi xe5 ??

    1. Yes it is using native controls, the same as iOS.

    2. As far as I know it does not use native controls - neither for Android nor for iOS. It uses "pixel-perfect" styles which can be stretched without loosing detail. This was one of the big problems with iOS 7 when XE5 only had styles for iOS6 and so apps made with FireMonkey in XE5 looked like iOS6 apps on iOS7. This has been updated now, I think.

    3. Hi,

      It has been updated now. At least this is what I know from the presentations.


  4. hi, you mention that the app is quite large for a simple online coding instruction. Do you then think its viable to develop relatively large apps like simple calculator programs?

    1. Hi,

      yes of course, I guess that the base project is quite large but then adding more and more stuff has no major impact on the size.


  5. Good to see that someone is willing to take first staps in mobile development.

    My main question about Delphi is how serieus development under android/iOS is.
    Are there some bigger Delphi apps in de Google playstore i can try, just to see how this app behaves?