Wednesday, December 29, 2010

Delphi for Android v0.3 Tutorial

Delphi Prism support iPhone and Android application development using Monotouch and MonoDroid where the goal of Delphi for Android ("Delphi Droid" for short) is to allow any developer that has Delphi 5 onwards to write Android applications.

This is a short tutorial on how to get started with Delphi Droid compiler version 0.3 as it currently is.

Note: The compiler isn't complete, there is still ALOT of work to be done. If you wish to help with the development, please contact me to contribute.

Requirements:
  • The Android SDK together with the Java SDK and Ant. Ant get used to compile the Android application since DelphiDroid generate a standard Android project (similar to how you do it using Eclipse)
  • Download DelphiDroid_v0.3.zip from the Google Code page.
  • Off course you need Delphi 5.0 or later.
  • .Net framework 3.5 run-time
What is in the ZIP:

Within the ZIP file you will find the following directories:
  • bin: There is where the compiler etc are located. You can set this as your SYTEM VARIABLE to call from command line.
  • DelphiDroid/DCCDroid: C# source code of the compile. This can be compiled using MS Visual Studio.Net 2008.
  • DelphiDroid/Framework: The "Delphi For Android" package that all Delphi applications require.
  • DelphiDTest: The Delphi example as in Sneak Preview 2 video.
  • Test: The actual Android projected generated by the compiler from the DelphiDTest example.
Setup Android SDK etc:

I'm not going to explain how to setup the Android SDK, I assume you already have knowledge on how to install the SDK, set it up etc.

Setup the compiler:

Within the bin folder you will find DCCDroid.exe.config file, open this using a plain text editor like Notepad:

  • Change the AndroidSDKDirectory to the location where you installed the Android SDK.
  • Change DelphiBinFolder to the location of the Delphi BIN folder that contains the Delphi compiler etc.
Run the sample program:

Open DelphiDTest and make sure it compile and run successfully in Delphi.

Run the compiler with no parameters:

Open the MS DOS Command prompt and run:

DCCDroid.exe

The output:

Delphi For Android 0.0.0.3 Dev Build
Copyright © 2010 by Lennie De Villiers

Invalid arguments, the following arguments are required:

Project Name - Name of the project
Activity Name - Name of the activity
Package Name - Java package name
Input Source Path - Delphi source directory path
Android Output Path - Android output directory path



So this is very basic command line parameters, i don't need to explain how they work.

You can open compile.bat file under the bin folder for an example:

dccdroid.exe DelphiAndroid DelphiAndroid com.test c:\Demo\DelphiDTest c:\Demo\Test
copy C:\Demo\bin\Android.Framework\*.* C:\Demo\Test\src\com\Test
cd c:\Demo\Test
ant debug

This will compile the example program (assuming the location like c:\Demo) , copy the Android libraries and compile the program.

When all is done you can run the run.bat file:

cd c:\Demo\Test\bin
adb shell rm /data/app/com.test.apk
adb -s emulator-5554 install DelphiAndroid-debug.apk

This will install the sample on the Android emulator.

You can look at compile.bat and run.bat to write your own compile/run scripts.

What is done:

Just like I said before, there is still ALOT of work to be done. Currently only the following components are supported:

TEdit
TLabel
TButton

References:


Mailing Lists:

Users:

http://groups.google.com/group/delphi-for-android-users

General users.

Developers:

http://groups.google.com/group/delphi-for-android-developers

Donations:

If you can't donate your time but wish to don't some money to help with the development, then please contact me.

Tuesday, December 14, 2010

Delphi For Android Future

Now what has Lennie been doing all the time? Am busy working on a new version of the compiler that got a couple of surprises in it... So stay tuned until next year in January 2011 when I will release the first version of the new compiler :-)