Categories
Android Mobile

Delphi XE5 Android Device Compatibility

Unlike iOS, there are are a huge variety of Android devices. Delphi XE5 supports the large majority of those devices. The official page for Android Devices Supported for Application Development spells out the requirements of Gingerbread, Ice Cream Sandwich or Jelly Bean on an ARMv7 processor (with NEON instructions). The NEON instruction requirement excludes the TEGRA 2 processor which was apparently popular in some tablets (mostly) a few years back. Also excluded is the Intel Atom processor, which I hear is showing up in Android devices in Japan.

If you look at the Android Dashboard we see those versions of Android make up 87.5% of the Android devices accessing the Android store. What that doesn’t tell us is how many of those devices have ARMv7 with NEON instructions. The DocWiki page also includes a number of devices that were tested for various functions, but really in the grand scope of possible Android devices it is a rather small sample.

Android versions pie chart

So I had the idea of using Apkudo. They provide an online service where you upload your Android app APK and they run it on a wide variety of devices and tell you how it did. Currently I’ve only done a “hello world” type app test, but it gives a good guide for devices that support XE5 at a minimum level.

They have 118 devices that run Android 2.3.3 (Gingerbread) or better (no Honeycomb). Our of those devices, my APK failed to install on 10 devices. Looking at the log it either timed out, or was out of storage space, so that may be more related to the state of the device before the test than any issues with the actual app.  Out of the 108 devices that loaded and ran the app, it only failed (ANR = Application Not Responding) on 3.

  • Devices tested: 118
  • Failed to install: 10
  • Locked up: 3
  • Successfully ran: 105
  • Success rate: 89%

From what I hear it isn’t uncommon for an app to fail for no reason on some of these devices, due to other influences (like no storage space). So that rate may actually be higherI’ve shared the full spreadsheet report here for you to look for your favorite devices. (They don’t provided a download of the report, so I had to transcribe it to the spreadsheet. There may be typos.)

I plan to modify some of our existing test apps and upload them. Since the test system just uses monkey it isn’t guaranteed to actually perform the specific actions of the test apps, so I need to automate that part of the app. When I do I will update that spreadsheet and provide an updated post.

I’m sure some people will point out that you could use Java and reached more devices. Instead of focusing on the small percentage of Android devices you are missing with Delphi XE5, I’d instead invite you to consider the millions of iOS devices you can target from the same code base. Including iOS 7!

You can get started now by downloading the Delphi XE5 trial.

Categories
Delphi Projects REST Source Code

Delphi XE5 Mobile REST Client Demo Source

With the release of Delphi XE5 I’ve made the source of the Mobile REST Client Demo available. This is a really super simple demo of the Mobile REST Client in XE5. It is designed to show up how you can consume a JSON REST Service and adapt it into a DataSet and then bind that to the UI. If you change the data source you will probably need to change the live binding.

I’ve changed the demo from the one I used in the video to consume an OData data source. OData is a new standard backed by Microsoft for sharing data over the web. You can think of it as SQL for the web. It is a combination of other technologies, including REST, AtomPub, and JSON. Sybase supports OData on all of their databases now, as does Microsoft and others.

The change was simply a matter of pointing it to the Northwind OData endpoint provided on Odata.org. The binding is setup to show the company name in the listview. I added the ability to specify a Root Element, but that isn’t necessary for the demo.

This new technology works in both desktop and mobile, FireMonkey and VCL. It should also work in C++ Builder.

[Download the demo] (MobileRestXE5.7z 8 KB – Requires Delphi XE5 – Builds for iOS, Android or Win32)

Categories
Android Debugging Mobile

Debugging Against a Remote Android Emulator

The Android emulator is impossibly slow when running inside a virtual machine. It is possible to debug against a remote emulator via SSH. Here are the steps to connect from a Windows guest OS to an OS X host OS (they can be easily adapted for a Windows host). It does require installing the Android SDK on the host OS and creating and running an emulator there. It seems to work even if you have a device connected too. I’ve gotten them both to show up in the IDE and am able to pick between them and deploy and run on the emulator.  The Emulator is still slower than hardware, but this makes it usable.

Of note, this emulator performance isn’t an issue with Delphi, but is an issue with the Android emulator. So you may find this tip useful with other Android development tools as well.

This could be adapted to debug against a remote Android Emulator running on a remote machine located anywhere on the internet. Just requires port 22 to be open between the two machines.

Thanks to hheimbuerger for the the Stack Overflow answer that got me pointed in the right direction. This information has been adapted to the DocWiki too with additional links to more information.

  1. Install the Android SDK (not the ADT bundle) on your Mac OS X host & start an ARM based emulator (With use Host GPU enabled)
  2. Enable SSH on the host
    • On a Mac OS X Host go to System Preferences -> Sharing -> Remote Login
    • On a Windows host, you need to install a 3rd party SSH host. FreeSSHd has been found to work.
  3. Install the PuTTY SSH (putty.exe) client on the Windows Guest OS
  4. Ensure port 22 is open between the Windows guest OS and the Mac OS X host.
  5. Create a connection in PuTTY to the Host OS
    1. You will most likely use the 192.168.x.x IP address of the host
    2. Go to Connection -> SSH -> Tunnels and add a local/auto port forwarding for 5555 to locahost:5555 and 5554 to localhost:5554.
  6. Save and Open the connection in PuTTY
  7. Provide the login credentials for the Mac OS X host – anything typed in this window is executed on the remote machine
  8. You can check or change the tunnel settings via the icon in the upper left of the PuTTY window
  9. Minimize PuTTY (keep it open to maintain the SSH connection)
  10. Open a new command window in the Windows guest OS and type “adb kill-server & adb devices” and you should see the emulator-5554 as a listed device.
  11. Refresh target devices in Delphi and it should appear

PuTTY Tunnels

This should work for any emulators or devices connected to the remote machine. Unlike emulators that are local, you need to start the emulators before Delphi will see them. You may need to adjust the tunnel port numbers if you are connecting multiple devices.

Good luck, and happy debugging!

Categories
News

MonkeyMixer updated for Delphi XE5

Delphi MVP and my friend Simon Stuart just updated his MonkeyMixer utility for XE5 (in addition to XE2, XE3 and XE4).

Once installed (and you’ll need to close the IDE before installing, by the way) you’ll be able to right-click on any VCL or FMX project in the Project Manager to toggle the project between VCL and FMX.
You do this by clicking Switch Project to FireMonkey or Switch Project to VCL(depending on what the project type is at that time).

Download the latest version. (Updated for XE6)

Keep in mind mixing FireMonkey and VCL forms in the same application isn’t officially supported, but this is a good option for migrating a VCL application to FireMonkey, or just including exactly the features you need.

Link to Simon’s post.

Categories
Delphi Projects News Source Code

Android Screen View

Android Screen View UI

People have asked for a copy of the utility I wrote to view the attached Android device on the screen. It uses the built in screencap functionality of Android and the ADB (Android Debug Bridge) to grab and display a series of screenshots. It requires the Android SDK installed and does not require a rooted device.

The speed of update has to do with the screen resolution and image complexity. Simple screens (text and controls) update about twice a second. More complex screens (pictures, graphics, etc.) are slower than that.

For best results, turn on “Show Touches” under debug options.

It also supports saving a PNG to file.

Get the source: https://code.google.com/p/android-screenview/

Download the build: http://delphi.org/downloads/AndroidScreenView.7z

There are a few pending features that I just haven’t gotten to. If you’d like to contribute let me know. Thanks to Stephen Ball for all his contributions already!

Categories
News

GExperts for XE5 Experimental Build

My good friend and Delphi MVP Jeroen Pluimers has just posted an experimental build of GExperts for XE5. He is working with Erik Berry to get an official build up on the GExperts site.

GExperts is a collection of open source productivity enhancements for Delphi.

[Download Experimental Build]

Categories
Source Code

Mobile Location on iOS and Android

Most Android and iOS devices either include a GPS antenna, the ability to triangulate off cellular or wireless access points, or some combination. Accessing the location is different when using the platform APIs for iOS and Android. Luckily Delphi XE5 includes the TLocationSensor component. When activated it has a OnLocationChanged event which fired when the location changes more than the specified distance. In there simply examine the NewLocation.Latitude and NewLocation.Longitude to know the current location.

Learn more about multi-device, true-native app development with Delphi XE5 and check out other Mobile Code Snippets.

Categories
Article

Tips for Solving Bugs

Ars Technica has compiled some tips for solving bugs quicker from a question on Programmers Stack Exchange. Here are the highlights:

  • Break out the notebook – keep a log of your progress and methodology
  • Look for patterns and use the right tools for the job.
  • Self-reflection time – a non-technical approach.
  • Read and apply Working Effectively with Legacy Code

Danny Thorpe, former Borland Chief Scientist, had a conference session on Reading Tea Leaves: The Fine Art of Debugging. Luckily Joe White took some great notes, and Danny revisited some of his tips in another Stack Overflow answer.

I’m curious what tips and techniques you have for solving bugs, especially those really nasty ones. Are there specific tools your use? I know there is a lot of functionality in the Delphi debugger, much of which is rarely used to its fullest potential.

Categories
News REST

Delphi XE5 Mobile REST Client Demo

Short demo of the new TRESTClient on a mobile Android application with Delphi XE5. It consumes a JSON REST service and uses the TRESTResponseDataSetAdapter to adapt it into a TClientDataSet. The TRESTClient components are new in Delphi XE5 and work everywhere Delphi does: Windows, Mac OS X, iOS and Android.

Learn more about multi-device, true-native app development with Delphi XE5.

Get the source code.

Categories
News

Sneak Peek of Delphi XE5: Android DataSnap

Quick demo of a DataSnap client on Android with a preview of Delphi XE5. Shows how easy it is to visually bind your data with design time preview, and how easy it is to move your mobile database client app from iOS to Android.

Learn more about Delphi for Android