Tuesday, 26 June 2012

Easy way to debug your Android apps over WiFi in Eclipse

There are some situations where debugging your Android app on emulator isn't enough. Maybe you need to test some native code (gamedev?) or just want to test some performance critical UI elements. There is a standard way to do it by USB cable and ADB. But there is more convenient way to do it.

When you have rooted phone you can do it over your WiFi network. There is a super easy way to set it up in eclipse environment. First, install ADB Connect plug-in on your Eclipse instance. The easiest way is to do it by Eclipse's internal update mechanism. Go to Help-->Install new software and add this source to the Location field: http://ppareit.github.com/AdbConnect/

Go through plug-in installation process and restart your Eclipse instance. Now you have to install this app on your phone. IT WILL ONLY WORK ON ROOTED PHONES! Start adbWireless when connected to your WiFi network. Click Window-->Preferences in Eclipse. Type adb in filter text filed, and set up your IP and Port number from adbWireless on your phone. Apply changes and click "OK".

 Now hit new icon on your Eclipse's toolbar (the one with Android mascot's head and "wireless" symbol). There might pop up some error message, click "OK" and don't worry about it. If the icon stays red, you probably have connection. Run your app as usual, if your minSdkVersion is equal or smaller than your phone's Android version, app should run just fine. You can test it on your phone with full feedback (DDMS, Debug mode, LogCat).

Monday, 11 June 2012

Great article about Palm's WebOS history

Last weekend I finally had the time to read this great article about history of Palm Pre and WebOS. Chris Ziegler did absolutely fantastic job putting it all together. I've been using couple of Palm devices since late 90's and there is now doubt modern mobile operating systems are inspired by this company's pioneer work. WebOS is technically dead but parts of it and ideas still live in Android (with little help from Matias Duarte) as well as iOS to this day.

I strongly recommend reading this article to anyone interested in mobile development. It's filled with a lot of surprising stories and insider info from Palm employees. And also great reminder of how fast things can change in the tech industry nowadays. Definitely not TL;DR!

Monday, 4 June 2012

How to set Android 4.0 x86 emulator with GPU emulation on Windows machine

Couple days ago Google (in collaboration with Intel) released x86 version of Ice Cream Sandwich emulator. I've been using x86 version of Android 2.3 emulator since firs release. It's considerably faster than ARM version (roughly 2-3x faster), so I couldn't wait for the ICS support.

You can combine it with GPU acceleration, so UI is snappy (faster than 2.3 x86 with the same resolution), and all cool ICS effects (like smooth transitions, gradients etc.) are available. I personally prefer to develop on VM rather than physical device. I'm using dual monitor setup, so It's more convenient to just have emulator running on second screen, than to distract yourself by switching from keyboard to tiny touchscreen device.

Here are my step-by-step guide how to install and configure it with Eclipse with ADT plugin on Windows machine:

1. First, before you start:

- I recommend installing newest version of Android SDK (19.0.0 when I'm writing this).
- Update your graphics card drivers (I tested it on nVidia GeForce 8800GT as well as on 8400GS which is roughly 10x slower than 8800GT but there was no performance differences on both cards running Android emulator). I recommend using drivers directly from your graphics card vendor. I had some problems with drivers downloaded by Windows update service.
- You need to have CPU supporting Intel VT-x technology (similar AMD technology is only supported on Linux - another reason not to buy AMD CPUs ;)). If you're not sure your CPU has it, you can always download CPU-Z (there is "no installation" version available, just download it, unzip and run). It will tell you your CPU specs. Red arrow on screenshot below shows where you can find info about presence of this technology.

 2. Run Android SDK Manager and download x86 system image.

3. Start Android Virtual Device Manager and add new device using specs from screenshot below. Add new filed in "Hardware" table called "GPU emulation" but leave it set to "no" value for now (I will explain why in a moment). You can choose whatever you like for "Name", SD Card "Size" values and device screen resolution. DO NOT ENABLE SNAPSHOT! Save machine but don't run in yet.

4. Download Intel Hardware Accelerated Execution Manager and install it. If you're tight on system memory you can decrease value of RAM used by VM. The VM will use all memory set in HAXM so you can easily change value to 512MB (more than plenty for ICS in 800x480 resolution and you can always change it by running HAXM executable after installation).

5. Now comes the tricky part. I'm not sure if that was my setup's fault, but VM refused to boot properly when I set GPU emulation on first start. So I recommend you start it up first without it. Run your VM, it can take a while to boot for the first time (2-3 minutes on my machine, you should see animated "Android" logo after about 30 seconds). You should get report that HAXM is working (more details are available in LogCat logs).

6. When it boots turn it off, edit preferences, set "GPU emulation" value to "yes", save it and try run it again. You can tell GPU emulation is working by opening system menu. Characteristic gradinet should be visible (right part of the screenshot below). If it won't start at first, try and run it again. After first successful boot there should be no further problems running VM.

As I said before, I strongly recommend giving it a try. This 2-3x performance difference is a huge deal and saves you a lot of time if you do a lot of Android development. Application testing process becomes much faster and enjoyable. The only drawback is the fact that in current version of x86 emulator (as well as when you use GPU emulation on ARM version) you can't use snapshots. After first boot emulator starts in about 2 minutes on my machine (Windows 8 RP, Intel Dual Core e5300@2,6Ghz, 4Gigs of RAM and (unfortunately ;)) 7200RPM modern HDD). But you only have to start it once during development day and leave it running so it's not that big of a deal.