January 4, 2012

From Delphi to Android

Android is bigger and bigger every day. What does this mean for Delphi programmers, how can you move knowledge and code? How can you program in Object Pascal for Android? An overview of the current options in a rapidly moving area.

Android is bigger and bigger every day. What does this mean for Delphi programmers, how can you move knowledge and code? How can you program in Object Pascal for Android? An overview of the current options in a rapidly moving area. 

It is about a month since I first considered writing a post on this topic, but given this is a rapidly evolving area I'm sure this is a better timing. having just seen two / three articles on specific technologies, I think it is time to get this moving. Let me first add a couple of personal considerations:

  • I think Android is big and will grow a lot. I've been using an Android phone for over an year, and I like it. Won't trade it for an iPhone or Lumia. I own an iPad, find it much more interesting than I anticipated (this is worth another post), but Kindle Fire, the coming GPad (Google iPad Clone), and more options will open this area to Android as well.
  • I think development tools for mobile are still in their initial stage and will grow, landscape will change.
  • I'm not generally terribly fond of code converters (sorry for those building similar tools, but I'm negatively biased).

Having said this which are the real and practical options for Delphi developers who want to build Android applications? These are the options I've noticed, let me know if I miss any, and if I missed any key information (feel free also to add more details, here I'm trying to provide summaries).

Alternative Android Development Options

Before we look to the available Delphi-oriented tools, let me try to summarize the options for building Android applications:

  • Writing Java applications for the Delvik virtual machine, generally using Eclipse and the Android SDK and plug-ins. This is the standard and mainstream appraoch.
  • Writing HTML + JavaScript Web applications optimized for the device, maybe using a library like jQuery Mobile. You can simply point users to URLs, or embed the page in a true Android Web App, and even interact with the device using a library like PhoneGAP. What's interesting in this model is that you can use the same application also on iOS.
  • Write native applications using the NDK, generally in C or C++.

Delphi Language Tools for Android

It is interesting to notice that different tools that bring the Delphi language (or Object Pascal) to Android follow each of the three models above. Here is a summary:

  • Oxygene for Java, by RemObjects, is a tool for writing Delphi-like code (or more Delphi Prism-like code) in Visual Studio converting it to Java for Android. Has a nice way to let you refer to any existing Java library, more or less like Prism does with .NET libraries. Read more at  http://www.remobjects.com/oxygene/java.aspx and Brian Long's article at http://blong.com/Articles/OxygeneForJavaIntro/OxygeneForAndroid.htm. With this tool you create Java applications.
  • SmartMobileStudio (formerly OP4JS) is a tool to convert Delphi code to JavaScript and create web applications. Official site is at  http://www.op4js.com/. Primoz has a nice article at http://www.thedelphigeek.com/2012/01/first-steps-with-smart-mobile-studio.html. I tend to disagree on the main rationale (JavaScript is low level / not good / too complex / etc), but still this tool might get you to code faster. With this tool you create Web apps.
  • Use FPC (Free Pascal Compiler) to build native apps, as detailed by Uwe at  http://www.bitcommander.de/blog/index.php/2011/12/19/fpc-android-boot/. After all, if Embarcadero is using FPC for iOS, it could also be good for Android. Still quite an early version, but interesting. And native.
  • Use Delphi DataSnap REST engine with a proper library to build Web Apps, like I did and documented on this blog at http://blog.marcocantu.com/blog/mobile_jquery_delphi_rest.html and http://blog.marcocantu.com/blog/web_andoird_app_delphi_datasnap.html. Yes, you need to write some JavaScrip, but can also use Delphi to generate some, as I do in my Relax Framework. You can probably use the JavaScript REST proxy also from SmartMobileStudio, but I'm not sure about this.
  • Use Eclipse ... and Delphi's Mobile Connectors for DataSnap. You can still write the core code and the database access code in Delphi, and code the UI in native Android Java. Or possibly use Oxygene for the front end, and Delphi for the backend. Or other server plus client solutions. Bittime has written a "Connect Four" app with this model, see https://market.android.com/details?id=com.bittime.connectfour&hl=en.
  • Wait... for a future Delphi for Android, and learn FireMonkey for now, as it seems likely the future, rumored, unofficially promised Delphi for Android will have the same user interface of the current Delphi / FPC for iOS, ties to OpenGL. At the 24 hours of Delphi, JT and DavidI promised a webinar for presenting the new roadmap in early 2012... so I'm waiting. Will this be a native / NDK solution? 

Again, there might be more options and alternatives, particularly in the Web App arena, but this offers you some alternatives... to get to Android or get ready for it. Awaiting your comments (better on the blog than on Facebook, but anything goes).





 

7 Comments

From Delphi to Android 

I'm surprised you've overlooked MonoDroid http://xamarin.com/monoforandroid
Comment by Mark on January 5, 01:27

From Delphi to Android 

Mark, good point about MonoDroid (it is a nice 
alternative), but I don't really see it as Delphi-
related.
Comment by Marco Cantu [http://www.marcocantu.com] on January 5, 08:04

From Delphi to Android 

Hi!

You've forgotten a point regarding FPC: Since around
August FPC (or more precisely: a not yet merged branch
of it) is able to compile code for the JVM (this means
generating normal .class files). In December this port
was extended by the possibility to compile code that
can be converted to the Dalvik virtual machine run by
Android. I used this to write my first Pascal JVM
Android app during the Christmas holidays.

For more information you can look at the following links:
Info about JVM Port: http://wiki.freepascal.org/FPC_JVM
Info about Android development (the article is not
perfect, but it's a start):
http://wiki.freepascal.org/FPC_JVM_Android_Development
The message where I announced my app: 
http://lists.freepascal.org/lists/fpc-pascal/2011-December/031689.html
(fpc-pascal list)
http://lists.lazarus.freepascal.org/pipermail/lazarus/2011-December/069470.html
(Lazarus list)

Regards,
Sven
Comment by Sven [] on January 5, 08:23

From Delphi to Android 

Small typo - it is "Delphi", but "Dalvik" (not
"Delvik"), and btw according to the Android docs, it
is not Java which runs on the Dalvik virtual machine,
but Dalvik byte code.
Comment by Michael Justin [http://www.habarisoft.com] on January 5, 10:41

From Delphi to Android 

 Good article summarizing Delphi options. As you say it's early 
days for mobile development, iOS and Android. There are a variety 
of non-Delphi options to Java (Android); here are some 'exotic' 
ones.

LiveCode (a la Revolution) runs on windows & Mac and has 
support for both native mobile environments (esp. iOS). Open 
source PhoneGap and Titanium generate native mobile apps from 
JavaScript, HTML, and PHP. Open-source scripting language Lua 
has free and commercial libraries for native apps, esp. Games. 
RadPHP from Embarcadero has wizards to prepare php apps for 
PhoneGap like NSBasic that uses a Visual Basic subset to 
generate JS code.

Alex
Comment by Alex McCullie [http://alexmccullie.com] on January 6, 08:39

From Delphi to Android 

+1 for DataSnapMobileConnectors.

Waiting for a Delphi for Dalvik compiler, we've using 
Java for client side and Delphi for the server side. Our 
DataSnap servers handle thousand of transaction every 
days.Very good technology.
Comment by Daniele Teti [http://www.danieleteti.it] on January 6, 10:28

From Delphi to Android 

Hello, Macro!
You forget to mention Raudus:
http://www.raudus.com/samples/
Raudus allows to create web-applications
for Android using Delphi, VCL controls and
Delphi RTL. Lazarus is also supported.
Comment by Igor Klopov [http://www.raudus.com] on January 8, 15:38


Post Your Comment

Click here for posting your feedback to this blog.

There are currently 0 pending (unapproved) messages.