Delphi for Android (aka Delphi XE5 aka RAD Studio XE5) has appeared

Blimey, that took me by surprise (again)! I figured it was coming fairly soon, but I didn’t realise quite that soon.

Anyway,Delphi XE5is here (as isRAD Studio XE5and siblings), as Tim Del Chiaro on hisDelphi Insider blog.

TheTrial Editionis up and available for download and those with Software Assurance should have access to the full version.

You can get a run down of what’s new in theXE5 doc wiki– specifically theWhat’s New page, but there’s also a generalWhat’s New page. However the thrust of this release is all about adding Android to the portfolio of supported target platforms, with the suggestion that you can get applications compiling for both iOS and Android from a single source base.

But before getting bogged down in Android it’s worth mentioning these new features:

  • the REST client library, a new cross-platform framework for easy access of REST-based web services
  • REST debugger
  • the full integration ofFireDAC
  • IDE support for MacinCloud
  • Extendible IDE mobiledesign devices
  • the awesomeIDE Insightfunctionality (Ctrl+.orF6) is no longer a modal dialog but is now a search box
  • style support for the freshly released iOS 7
  • swipe to delete feature on mobile platforms
  • TListViewsearch filtering support
  • the removal of the long defunct WebSnap and InternetExpress (with the suggestion to useIntraWebandWebBrokerinstead for similar functionality)

Also there have been a bunch of iOS fixes along the way, as you’d expect.

The full Delphi range of platform targets now covers:

  • 32-bit Windows
  • 64-bit Windows
  • 32-bit OS X
  • iOS Simulator (Intel)
  • iOS (ARM)
  • Android (ARM)

This is achieved with this half dozen compilers:

  • dcc32 – Embarcadero Delphi for Win32 compiler version 26.0 – your regular Win32 Delphi, the latest version updated over many versions since Delphi 2
  • dcc64 – Embarcadero Delphi for Win64 compiler version 26.0 – the 64-bit Windows targeting compiler
  • dccosx – Embarcadero Delphi for Mac OS X compiler version 26.0 – the Delphi compiler that generates 32-bit OS X apps
  • dccios32 – Embarcadero Delphi Next Generation for iPhone Simulator compiler version 26.0 – the NextGen Delphi compiler that builds Intel executables that run in the iOS simulator
  • dcciosarm - Embarcadero Delphi Next Generation for iPhone compiler version 26.0 – the NextGen Delphi compiler that builds ARM executables that run on iOS devices
  • dccaarm – Embarcadero Delphi for Android compiler version 26.0 – the NextGen Delphi compiler that builds ARM executables that run on Android emulators and devices

Android requirements

Because the Delphi compiler generates native machine instructions, its output is processor-specific. In other words it doesn’t target the Dalvik Virtual Machine, where regular Android applications reside, which are basically Java p-code applications that are executed by a variant of the Java VM. Instead it generates raw machine code, as all the current wave of Delphi compilers do (the long gone Delphi for .NET was the exception to this general rule). So because it’ a compiler compiling native machine instructions Delphi’s Android support has the following requirements:

  • there must be a GPU
  • the CPU must be ARMv7 with NEON instruction support
  • the OS on the target device must be one of:
    • GingerBread: Android 2.3.3+ (MR1 or later), which is API level 10
    • Ice Cream Sandwich: Android 4.0.3+ (MR1 or later), which is API level 15
    • Jelly Bean: Android 4.1+ (release, MR1, MR2 or later), which are API levels 16, 17 and 18
  • you can run the app on an Android emulator if:
    • the emulator is set to use the host GPU
    • the emulator is running Ice Cream Sandwich (MR1 or later) or Jelly Bean (release or later)
    • the emulator is not running in a Virtual Machine

These requirements appear here and there in the documentation, mostly concurring with itself:1,2.

How do you find out if your device is supported? Well, the OS version you can find out in the Settings. The path and menu items may vary but goes roughly like this: Settings, About phone (or tablet), Software information, Android version.

To check the CPU details you’ll need to run one of the tools from the Android SDK against your connected device. Delphi installs the Android SDK and NDK if you don’t tell it you have it pre-installed. The Android SDK gets installed into a directory something like: C:\Users\Public\Documents\RAD Studio\12.0\PlatformSDKs\adt-bundle-windows-x86-20130522\sdk. In the platform-tools subdirectory from there is theAndroid Debug Bridge, adb.exe.

To run a command against your device it needs to be connected, typically by USB. This requires you to install an appropriate USB driver for your device as the ones located by Windows typically don’t do the job. Refer to the helpful The Delphi Geek blog post on the matter,XE5 and USB Drivers, for more information and links to drivers for the more common Android phone manufacturers.

When your phone is connected you’ll need to launch a command prompt and run anadbcommand. This may be easiest if you change directory to the platform-tools subdirectory (orShift+right-click on the platform-tools folder in Windows Explorer and choose Open command window here). Firstly run the command:

adb devices

just to prove that your device can be seen by the Android tool chain. Assuming it can, run:

adb -d shell cat /proc/cpuinfo

This will show you CPU information something like this:

Processor :ARMv7Processor rev 0 (v7l)
processor : 0
BogoMIPS : 13.52

processor : 1
BogoMIPS : 13.52

processor : 2
BogoMIPS : 13.52

processor : 3
BogoMIPS : 13.52

Features : swp half thumb fastmult vfp edsp thumbeeneonvfpv3 tls vfpv4

CPU implementer : 0x51
CPU architecture: 7
CPU variant : 0x1
CPU part : 0x06f
CPU revision : 0

Hardware : UNKNOWN
Revision : 0003
Serial : 0000000000000000

Check the Processor line to ensure you are runningARMv7. In the Features line check thatneonis included in the CPU feature list

Product Launch

There have been various events worldwide over recent fays and more coming in the days ahead, spreading the word about the new Android support in Delphi XE5. Today I attended the London event, which was held in a theatre in theNatural History Museum.

Embarcadero’sJTwas over to help with the launch, and also on stage wereJason VokesandSteve Ball.

I was a long way back in the audience with the zoom on my telephone’s camera on maximum. But this was the theme for the day.

Addenda

If you are keen to try out Delphi’s Android support, go right ahead and start downloading and installing. However I would urge you to read up on how Android development works whilst the download/install process takes place. There are many docwiki pages that help you get a handle on how it all fits together with the main entry point here:Android Mobile Application Development. A whole bunch of subtopics are listedhere.

Recent posts about Delphi’s Android support, which pre-dated today’s launch, include the following:

  • Compiling Android Apps with Delphi - Marco Cantù
  • YouTube in a Delphi Android App – Marco Cantù
  • Pizza Time – Azure Data on Android with Delphi – Marco Cantù
  • Sneak Peek: Android SDK, NDK and Device Support in Delphi
  • Delphi Brings ARC to Android - Marco Cantù
  • Printing from an Android Device using FireMonkey - JT
  • FireMonkey Icons on my Google Nexus 4 - Marco Cantù
  • It’s alive! A first look at Delphi for Android - JT
  • Updated Delphi Roadmap - Marco Cantù
  • RAD Studio Mobile Roadmap
  • Getting ready for Android - Robert Love
  • XE5 News: Coming in September, With Android Support - Jolyon Smith

In aprevious blog postI discussed the Objective-C Bridge, available when building iOS apps. This is part of the RTL that allows Delphi code to interact with Objective-C API code. Objective-C code is compiled native code and Delphi code is compiled native code, so the bridge allows the two sets of code to get along. You can define Delphi versions of iOS classes (rather akin to how you can declare Delphi versions of Win32 API functions in classic Delphi), create instances of Objective-C classes, inherit from Objective-C classes and generally do what is necessary to access parts of the CocoaTouch API that are not consumed and surfaced by FireMonkey or parts of the API that do not have similar behaviour exposed by FireMonkey.

Oh, I should mention it’s not so much called FireMonkey now. It seems to be getting referred to more and more as the FM Application Platform. I suspect the latter sounds a little more “business”-y.

Anyway, the Android support offers a similar API bridge called the Java Bridge. Now the Android SDK classes are Java classes living in the world of the Dalvik VM. Delphi code is machine code running on the CPU. This is different to the iOS case. So the Java Bridge uses JNI to communicate across the native/managed boundary but basically offers broadly similar behaviour. You can declare Delphi versions of Android classes, create instances of them and communicate with them. So aspects of the Android API that do not get employed by regular Delphi apps can be accessed for the most part.

One shortcoming of the Java Bridge is that you cannot inherit from a Java class, which makes certain things rather tricky. However I’m going to write up my understanding of the Java Bridge and Objective-C Bridge in additional fuller articles with various examples over coming months, and try and offer ways around the Java Bridge shortcomings. Watch this space. Well, ok, you’d do better to read up on all the Android backgrounders in docwiki while downloading and installing XE5 :o)

Here are some more Embo pages for you to chew over and apply due consideration to:

  • Delphi Overview:http://embt.co/DelphiXE5
  • RAD Studio Overview:http://embt.co/RADStudio
  • One Codebase One Team:http://embt.co/1CodeBase
  • RAD Studio Android:http://embt.co/RADAndroid
  • Delphi Android:http://embt.co/DelphiAndroid
  • Multi-device True Native:http://embt.co/MultiDevice

更多相关文章

  1. 代码中设置drawableleft
  2. android 3.0 隐藏 系统标题栏
  3. Android开发中activity切换动画的实现
  4. Android(安卓)学习 笔记_05. 文件下载
  5. Android中直播视频技术探究之—摄像头Camera视频源数据采集解析
  6. 技术博客汇总
  7. android 2.3 wifi (一)
  8. AndRoid Notification的清空和修改
  9. Android中的Chronometer

随机推荐

  1. 分享 1 个一次性免费获得极客时间 2-3 个
  2. 《Java入门1•2•3》读书笔记
  3. 该不该造自己的轮子?
  4. 解答 H 大的公布的 10 道 Java 测试题
  5. 《***与画家》读书笔记
  6. MySQL 如何进行慢 SQL 优化?
  7. 冒泡排序(Java)
  8. @Transactional 注解哪些情况下会失效?
  9. 使用 @ControllerAdvice 注解,优化异常处
  10. 设计模式使用场景、优缺点汇总