Categories
MVP

New MVPs & Directory

Another round of new Embarcadero MVPs

  • Chris Rolliston
  • Marcos Lizarraga
  • Rudy Velthuis
  • Christina Louise Warne
  • Bertie Buitendag
  • CHUA Chee Wee
  • Warren Postma
  • Bruce McGee

You can learn more about them, and our other MVPs in the newly redesigned MVP Directory.

Here are some pics of a few of the MVPs

Brazil

The Brazilian MVPs from the Embarcadero Conference a couple weeks ago!

Samuel1

A picture by Samuel David to promote his session at the conference.

Samuel2

He wore the leather coat and hat all day too, even when posing with the Android!

Xavier1

This is a picture of Xavier Martínez. That is him on the bottom. He is involved in Castells or “Human Towers”. Pretty amazing if you ask me!

Xavier2

Categories
Android Debugging

8 Tips to Speed Up Your Android ARM Emulator (AVD)

The Android Emulator is very slow. The main reason is because it is emulating the ARM CPU & GPU, unlike the iOS Simulator, which runs x86 code instead of the ARM code that runs on the actual hardware. This means the iOS Simulator is typically faster than actual hardware, and the Android Emulator is slower than actual hardware. Most Android developers I talk to develop on actual hardware, but sometimes you need the emulator, and when you are using it you need it to run faster.

You may see some articles or tips about using the Intel HAXM, BlueStacks, Genymotion, Android-x86 or some other high performance Android emulator. These almost always are using an x86/Atom Android image, which runs faster because it doesn’t need to emulate the CPU, running x86 code on your host CPU (much like the iOS Simulator). Yes, they are faster, but the majority of Android devices (in the USA at least) are ARMv7. So you are technically testing on a niche hardware configuration that is not likely to be what your app runs on in the real world. In some parts of the world, Intel Atom based Android devices are becoming more common, so those emulators do serve a purpose.

The Android Emulator runs an Android Virtual Device or AVD. You can configure and create different Android Virtual Devices with the Android Virtual Device Manager or from the adb command-line tool.

Here are some tips to make the ARM Android emulator faster for any Android development tool, but my examples are specific to Delphi XE5. Many of these tips can be combined for better performance. Using these tips I’ve seen the emulator go from sluggishly terrible to actually usable on a few different systems.

  1. Use Actual Hardware – OK, so this doesn’t speed up the emulator, but it is worth mentioning again. There are a number of other advantages besides speed, and Android hardware is pretty cheap compared to iOS hardware. Get a few different devices, and you are set.
  2. Don’t Run the Emulator in a Virtual Machine – The emulator is a virtual machine, and running a virtual machine in a virtual machine just compounds the problem. If you are developing in a virtual machine, all is not lost, you can still debug against a remote emulator to run the emulator on the host machine.
  3. Use Parallels Desktop 9 – If you must run the emulator in a virtual machine (which I don’t recommend) I hear reports that Parallels Desktop 9 for Mac OS X is faster than VMWare Fusion. You can test this for yourself with the latest version of VMWare Fusion. The comparison I heard about was between Parallels 9 and Fusion 5, which is now a version behind.
  4. Use Host GPU – There is an option when creating an Android Emulator Instance (called an AVD or Android Virtual Machine) to use the physical GPU on the host machine instead of emulating it in software. This gives a huge performance boost. So create a new Android Emulator, and make sure to enable Use Host GPU. (Not, this is incompatible with the other performance option of Snapshot, but I’ve found Use Host GPU results in better emulator performance, while Snapshot only speeds up emulator startup.)
  5. Copy the OpenGLES libraries – After launching an emulator with Use Host GPU enabled, sometimes you get an error “Could not load OPENGLES emulation library”. If you do, then use this tip (if you don’t get the error, then skip this tip).OpenGLES errorThis has two common causes, the first is fixed with a reboot. If that doesn’t work then you need to copy the necessary DLLs to a different directory so the emulator can find them. Simply copy lib*.* from C:\Users\Public\Documents\RAD Studio\12.0\PlatformSDKs\adt-bundle-windows-x86-20130522\sdk\tools\lib up one folder to C:\Users\Public\Documents\RAD Studio\12.0\PlatformSDKs\adt-bundle-windows-x86-20130522\sdk\tools (this is assuming you are using the Android tools installed by RAD Studio. Adjust your paths as necessary). Relaunch the emulator and the error should go away, and your emulator should be much faster. There is another method that involves updating path information, but just copying the necessary files is easier.
  6. Run your Emulator on a Mac – I’ve heard reports that the OpenGLES libraries are faster on Mac OS X than on Windows, because Windows prefers DirectX, while OS X prefers OpenGL. You can use the remote emulator setup to make that work (assuming you have a Mac handy). Likewise, if you have a computer with a newer and more powerful GPU and CPU, then use that one. Be sure you combine this tip with the previous two (to Use Host GPU).
  7. Run an Older Version of Android – Sure, Kit Kat is new and Shiney, but not everyone has it yet. The newer versions of Android are typically more demanding on the hardware, so newer  may be slower. Check out the Android Platform Version Dashboard and go back to an older, popular version, or just stick with Gingerbread and know you will support close to 98% of all Android devices.
  8. Tweak the AVD Hardware Configuration – One advantage of the using the Android Emulator is you can test specific hardware configurations, so this one is less useful. But if you increase the memory (within reason) and make the screen smaller (again within reason) that can give you a minor performance increase too.

Generally speaking, I would suggest everyone use tips 2, 4, 5 and maybe 7, but everyone’s situation and needs are different, so pick and test the tips that give you the best Android Emulator AVD performance possible. Good luck, and happy Android development and debugging!

Categories
Android News

More Complete Supported Android Devies List

The Delphi Wiki has a much more exhaustive Supported Android Devices list. It also includes the new Nexus 5 (running Kit Kat), Google Glass and Droid Razr M, to name a few. At the bottom of the list there are some BlackBerry devices listed too, all of which are either not tested, or not supported. Curious to see if any of those end up working

There is also a link to some easy to follow testing instructions if you want to test your own devices, including some scripts to help automate part of the process.

Looking at the list it is obvious that there are more supported devices than not. Most pass over 80% of the tests too, of course it is always nice to see specific devices verified.

Categories
Android Tools

Installing and Running Android Apps From Command-Line

Delphi automatically installs and runs your app for you, but sometimes it is nice to do manually from the command-line. Here are the commands you need. These all assume adb (Android Debug Bridge) is on your system path and you only have one Android device (or emulator) attached. They should work on both Mac and Windows.

See the end for notes on multiple devices or if you are running both an emulator and device.

First to install your app:

adb install path\ProjectName.apk

In this example path\ProjectName.apk is the full relative path to the apk. The apk usually has the same name as the project. If your apk is already installed, then use the following command to “reinstall” it, leaving the data intact:

adb install -r path\ProjectName.apk

The great thing about the -r is it works even if it wasn’t already installed.

Now if you want to uninstall your apk you can do that too:

adb shell pm uninstall -k com.embarcadero.ProjectName

Again, com.embarcadero.ProjectName is the default name of the package. If you changed it under Project Options -> Version Info -> Package, then use that value instead. BTW, the pm in there is the Android Package Manager.

One note, when Delphi deploys your app to run it, it performs an uninstall first. This results in all the data being cleaned out, which can be useful during development to be sure you don’t leave anything behind from the previous run. When a user updates an app from the App store, or installs it via most any other means, then it performs a reinstall, which leaves the data intact.

Now if you want to run it, things get a little more interesting. Now we use the Android Activity Manager (AM).

adb shell am start -n com.embarcadero.ProjectName/com.embarcadero.firemonkey.FMXNativeActivity

There are two parts to this. Before the slash is the package name, just like for uninstalling it. After the slash is the name of the Main Activity, which unless you’ve edited your AndroidManifest.template.xml (and some other fundamentals of your app) is always com.embarcadero.firemonkey.FMXNativeActivity. If you are trying to start an app written with another tool, then consult the AndroidManifest, but it is common for most tools to use MainActivity, so you can launch it like:

adb shell am start -n com.other.ProjectName/.MainActivity

If you want to stop your app after it is running, you just need the name of the package and the following:

adb shell am force-stop com.embarcadero.ProjectName

This can be useful to test what your app behaves like from a fresh restart, vs. just returning from the background.

The Android adb tool is very powerful. Most of these are using the shell command which actually allow you to pass commands to the modified Linux shell that runs inside Android. You can actually use “adb shell” to open a shell prompt and navigate your device like a remote machine.

If you have both an emulator running and a device attached then you can use the switch -d like

adb -d shell

and it directs it to the only device. If you use -e then it goes to the emulator.

When you have multiple devices then use -s and the device ID which can be obtained via the adb devices command.

There are so many other useful things you can do with adb. Check out the documentation.

Categories
Conferences News

Stops on My North America Tour

I just got back from Brazil and Costa Rica, which was great. Now I am headed out to different cities in North America (Yes, technical Costa Rica is in North America, but all these cities are north of Latin America). David I and Al Mannarino are also traveling across North America for a total of 27 cities. Here are my city stops:

Minneapolis – Meet and Eat
Wednesday, November 13, 2013 @ 12:00pm-2:00pm
Ruth’s Chris Steakhouse
920 2nd Avenue S #100, Minneapolis, MN
[Register]

St. Louis – Meet and Eat
Thursday, November 14, 2013 @ 12:00pm-2:00pm
Ruth’s Chris Steakhouse
315 Chestnut Street, St. Louis, MO
[Register]

Chicago – Hands on Workshop
Saturday, November 16, 2013 @ 9:30am-3:00pm
Hyatt Regency Woodfield – Schaumburg
1800 East Golf Road, Schaumburg, IL
[Register]

  • Wed, 20-Nov Vancouver, BC 12:00pm 2:00pm PST [Register]
  • Thu, 21-Nov Calgary, AB 12:00pm 2:00pm MST [Register]
  • Tue, 3-Dec Bellevue, WA 12:00pm 2:00pm PST [Register]
  • Tue, 3-Dec Bellevue (User Group), WA 6:00pm 8:00pm PST
  • Wed, 4-Dec Portland, OR 12:00pm 2:00pm PST [Register]
  • Wed, 4-Dec Portland, OR (User Group) 6:30pm 8:30pm PST
  • Thu, 5-Dec Boise, ID (User Group) 7:00pm to 9:00pm MST [Register]

I’m planning to bring my Google Glass and show off Delphi XE5 running on Google Glass too.

Categories
Android Delphi Projects Mobile News REST

Hello Google Glass from Delphi XE5

Google’s new Glass platform is a very revolutionary Android device, but the question I really wanted to know is if I could develop for it with Delphi XE5. Turns out the answer is Yes.

There are actually two different options for developing Glassware: Mirror API and GDK.

The first is the Google Mirror API, which allows you to build services, called Glassware, that interact with Google Glass. It provides this functionality over a cloud-based API and does not require running code on Glass. This is accomplished through a REST and JSON based API. Thanks to the new TRESTClient components in Delphi XE5 this should be easy enough to do.

The GDK on the other hand is the avenue where you build an actual APK that runs on the Google Glass device itself. This gives you the most access to the device, its sensors and features. Turns out this is also easy enough to do with Delphi XE5.

The actual GDK builds on top of the Android SDK. You can develop apps to run on Glass with either the Android SDK or GDK, but the GDK is necessary to take advantage of some of the Glass specific features.

If you run SysCheck on Glass (which takes some effort) you discover it has an ARMv7 PRocessor rev 3 (v71) with Android OS Version 4.0.4 and NEON support. Those meet the main requirements for Delphi XE5 development. So I created a simple Hello World app and ran it.

This first screenshot shows Glass appearing in the Project Manager as a valid target (once the required USB drivers were installed, which was tricky for glass).

HelloGlassProjectManager

Here is a screenshot of the app running on Glass

Delphi XE5 App running on Google Glass

I didn’t hide the status bar, which most Glassware does, and it does nothing other than serve the purpose of showing a Delphi XE5 app running on Google Glass. There were no special settings (other than the dark theme, which is a matter of taste) to make the app run on Glass. It just works.

And lastly a quick selfie of me and Glass, taken through glass.

JimWithGlass

I was hoping it would look more red than orange, but should have known Tangerine would be orange.

Rest assured, there will be more coverage of Delphi and Glass. We are just getting warmed up. This app was not using the GDK (which is still in Beta) but it is an actual Delphi app running on Glass. What an exciting day!

Categories
Android

Wireless Android Debugging with Delphi xE5

Previously I blogged about how to connect to an emulator on a remote (or the host) machine. That also works for hardware connected to remote machines. But sometimes you want to work with hardware that isn’t even connected at all. Not to worry, here is how to wirelessly connect and debug with your favorite development tool. One note though, WiFi slower than a USB connection, so you will see a little delay sometimes.

Requirements:

  • A machine (Mac or PC) you can connect the Android device to that has ADB (Android Debug Bridge) installed. This is part of the Android SDK. As well as necessary ADB USB Drivers (required on Windows). This can be your development machine, or another machine.
  • A non-segmented wireless network that both your development machine and Android device are connected. (Segmenting prevents two connected devices from connecting to each other).

These commands work with ADB (Android Debug Bridge). It is easiest if you add it to your path. By default it is found in the following location, but you can install it anywhere on your system (Select the “Use An Existing IDE” option when downloading).

C:\Users\Public\Documents\RAD Studio\12.0\PlatformSDKs\adt-bundle-windows-x86-20130522\sdk\platform-tools

First you need to connect your Android device to any computer. With USB debugging turned on, verify you have access to the device via ADB with the following command:

Command:

adb devices

Output:

List of devices attached 
8605fa72        device

If the list is empty, then you need to enable USB debugging and make sure you have the USB ADB Bridge driver for your device installed.

Once ADB is setup, you can get the IP address with the following command:

adb shell netcfg|grep wlan0

Which should give you output like:

wlan0  UP     10.20.5.88/24  0x00001043 2a:32:11:42:aa:3c

Then put the device in TCPIP mode with the command:

adb kill-server
adb tcpip 5555

Then on your machine that is running Delphi XE5 go to the command window and type (with the IP address from above):

adb connect 10.20.5.88

Then you can verify it worked from that same command prompt

Command:

adb devices

Output:

List of devices attached
10.20.5.88:5555   device

And now you can connect to that device wirelessly from Delphi. Like I mentioned before, this is slower, so expect some delays on deploy and responding to breakpoints.

There is some more information on Stack Overflow, including some different options if you have a rooted Android device.

Categories
Conferences

Things I Learned from Delphi CodeRage 8

Mostly from CodeRage 8, but some is from my time working for Embarcadero. I believe I’ve presented at every CodeRage, but this is my first time on the other side. It is also the biggest CodeRage by a significant margin. I’m sure the two events are unrelated, but it is still exciting.

  • Delphi can do functional programming, and it is really cool.
  • Cary Jensen is really excited about FireDAC – and so is everyone else, because FireDAC is really cool. He’s so excited he might cut his hair off . . .
  • There are a lot of really smart and very nice people working for Embarcadero.
  • No matter how easy you find it to understand someone, there is somebody else who has a hard time with their accent, speed, or terminology.
  • There is still more that I don’t know about Delphi then I do. And I think that is a good thing.
  • You really shouldn’t use “with” in your code, especially during a presentation that occurred after Alister Christie‘s session on “anti-patterns.”
  • The Tag property is useful, but no one wants to admit it.
  • Delphi makes it easy to make nice UI and ugly UI. I like that it is flexible.
  • If you use something wrong it will be slow. If you test you can probably find a faster way.
  • Two people can present on the same thing and have different sessions while two other people can present on two different things and have surprising overlaps.
  • REST and JSON are great, but XML and SOAP are still around and in use.
  • If you want to scroll it, use a TListView. Otherwise use a TListBox.
  • When it comes to making custom controls, in any framework, Ray is still the guy.
  • It is a lot more work than I expected to run CodeRage, but also a lot more fun.
  • If you know what you are doing, it is pretty easy to access any iOS or Android API from Delphi.
  • You can use FireMonkey to make a pretty good mobile game, but it still isn’t recommended.
  • Encrypt your customer’s data, or you can get a huge fine.
  • Everyone always likes a good benchmark or comparison, but they don’t really tell you anything.
  • David I. really is as great of a guy as everyone says he is, but even 3 days of CodeRage will wear him out.
  • The Android Emulator is really slow and unresponsive, and no one seems to know why.
  • There usually is more than one way to do something. And just when I think I realized a smart way to do something, someone else will point out an easier way.
  • Replay videos are never online fast enough.
  • Making a good video to explain a technical topic is way more work than anyone realizes, even people who have done it a hundred times. And when you are done you are rarely satisfied with it.
  • GoToWebinar is a pain, but so far it seems to be the best option.
  • Even in a pre-recorded video, people will still help you find the typos in your code.
  • Questions can take longer than the session the questions are about.
  • Delphi developers really are amazing!

And some answers to frequently asked questions:

  • The code will usually be on the presenters blog.
  • Replays will be a couple weeks.
  • Turn on “Use Host GPU” in your Android emulator and don’t run your VM in an Emulator. Better yet, buy an Android device. The emulator is slow for everyone, which is why most Android developers don’t use it.

I learned a lot more, but those were the memorable bits that came to mind.

What did you learn?

Categories
Android Conferences iOS Mobile

Sending a URL to Another App on Android and iOS with Delphi XE5

Here is the source code for my Open and View URL library from my CodeRage 8 session “Beyond the App”. Here is a download of the example app. I’ll see about posting it to a SVN repository too so it can grow and evolve. Thanks to Al Mannarino for his code that started this!

Note the code is using TidURL.URLEncode on all URLs. I found it is only required on the maps for iOS (iOS doesn’t like spaces) but may be causing trouble with the geo:// on Android.

Some example protocols

  • http, tel, sms, fb, mailto, twitter, geo, etc.

Example URLs

  • – Common to both iOS & Android –
  • http://www.embarcadero.com/
  • tel://(415)834-3131
  • sms://1234
  • http://twitter.com/coderage (This opens with the Twitter client on Android)
  • mailto://jim.mckeeth@embarcadero.com
  • twitter://user?screen_name=coderage
  • fb://profile/34960937498 (get the UID from http://graph.facebook.com/embarcaderotech or for whatever page you are looking for)
  • – iOS Specific –
  • http://maps.apple.com?q=5617 Scotts Valley Drive, Scotts Valley, CA 95066 (this needs the URL encode – Apple has some additional APIs that are recommended.)
  • – Android Only –
  • content://contacts/people/
  • content://contacts/people/1
  • geo://0,0?q=5617 Scotts Valley Drive, Scotts Valley, CA 95066
  • geo://46.191200, -122.194400 (I think this one doesn’t like the URLEncode)
unit OpenViewUrl;

interface

// URLEncode is performed on the URL
// so you need to format it   protocol://path
function OpenURL(const URL: string; const DisplayError: Boolean = False): Boolean;

implementation

uses
  IdURI, SysUtils, Classes, FMX.Dialogs,
{$IFDEF ANDROID}
  Androidapi.Helpers,
  FMX.Helpers.Android, Androidapi.JNI.GraphicsContentViewText,
  Androidapi.JNI.Net, Androidapi.JNI.JavaTypes;
{$ELSE}
{$IFDEF IOS}
  Macapi.Helpers, iOSapi.Foundation, FMX.Helpers.iOS;
{$ENDIF IOS}
{$ENDIF ANDROID}

function OpenURL(const URL: string; const DisplayError: Boolean = False): Boolean;
{$IFDEF ANDROID}
var
  Intent: JIntent;
begin
// There may be an issue with the geo: prefix and URLEncode.
// will need to research
  Intent := TJIntent.JavaClass.init(TJIntent.JavaClass.ACTION_VIEW,
    TJnet_Uri.JavaClass.parse(StringToJString(TIdURI.URLEncode(URL))));
  try
    SharedActivity.startActivity(Intent);
    exit(true);
  except
    on e: Exception do
    begin
      if DisplayError then ShowMessage('Error: ' + e.Message);
      exit(false);
    end;
  end;
end;
{$ELSE}
{$IFDEF IOS}
var
  NSU: NSUrl;
begin
  // iOS doesn't like spaces, so URL encode is important.
  NSU := StrToNSUrl(TIdURI.URLEncode(URL));
  if SharedApplication.canOpenURL(NSU) then
    exit(SharedApplication.openUrl(NSU))
  else
  begin
    if DisplayError then
      ShowMessage('Error: Opening "' + URL + '" not supported.');
    exit(false);
  end;
end;
{$ELSE}
begin
  raise Exception.Create('Not supported!');
end;
{$ENDIF IOS}
{$ENDIF ANDROID}

end.
Categories
Android iOS Mobile

Reading Barcodes with XE5 – Preliminary post

Fernando Rizotto has an example of using XE4 on iOS to read a barcode. He is using an iOS specific library. Another library that is available on both iOS and Android is OpenCV. It is a full open source computer vision library with a lot of great features, one of which is reading barcodes.