Following on from my recent post on AVD performance issues, it seemed a good time to share one or two other practical tips and tricks about working with the AVD.
When testing, I really do not want to have to click on the on-screen keyboard to enter text. Unfortunately, with the latest Android Developer Tools (ADT 20.0.3), the default settings are exactly that. To enable your PC keyboard for the emulator: go to the Edit AVD screen. In the hardware section, add a new property: Keyboard support and click OK. Then click the value next to the Keyboard support property and set it to YES. Now, when you start the AVD, you can enter text from the PC keyboard. I have to confess that I am baffled as to why the default was changed to NO in the latest release.
The Windows 7 implementation of the SDK (20.0.3 again) seems to have a strange bug indeed. If you create an AVD with anything except the default (WVGA800) resolution, it crashes during start-up with a memory error: 8. This is maddening! Fortunately, thanks to the guys at Stack Overflow, I was able to find a solution to this one pretty quickly. What you do is to first select the resolution you want from the built-in skins list and then replace the resolution with the actual values. So for the WXGA720 skin, you first select that skin then set a specific resolution of 1280*720 and it works! I have not tested either the failure or the solution on every screen resolution but it certainly got me up and going!
Lastly, for this post at least is what to do when you get error’s trying to deploy your application to the AVD. These errors, will typically say that there is no AVD running or perhaps bounce you into the DDMS console on Eclipse with a message indicating a problem with something called ddmlib. There is no single solution to these problems but I have a well-practiced set of steps I go through which usually resolves the problem.
The issue lies with one of three components: the AVD, ADB (Android Debug Bridge) or Eclipse. The first suspect is always ADB and it’s best to restart it. There are two ways of re-starting ADB. Either open a terminal and type adb kill-server followed by adb start-server (I assume you have adb on the path) or you can do it from Eclipse: select the DDMS perspective, the very last icon in the Devices window toolbar is an arrow which accesses the View menu. From the View menu, select reset adb. Cynics might wonder at the fact that rather than fix the ADB issues, the developers have created a menu option to reset the tool!
If that fails, restart the AVD. If even that fails, restart the AVD and select Wipe user data. Still failing? Restart Eclipse. If you still can’t get communication between Eclipse and you AVD, shut the machine down and go for a walk. Hopefully, it will haved fixed it’s self when you get back. If not, try creating a completely new AVD. Still not working: sorry, by now it’s always worked for me!