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).