Grab Android Screenshots from Linux: No Rooting Required

528

Getting a screen shot should be easy, shouldn’t it? On Android, not so much. While it’s trivial to get screenshots on the Linux desktop and on some other mobile platforms, Android is a different story. If you need or want to get Android shots, without rooting your device, you can — using the Android SDK. Here’s how, in as few steps as possible.

But why bother getting screen shots from a mobile device? That’s actually an easier question to answer than you might think. I am the Android support specialist (among many other things) at a local consultancy. There are many times I have to instruct clients how to do something or configure something over the phone. When that happens, I have (on occasion) taken screen shots and sent the image to the client via email. That made the process of support quite a bit easier.

It would, however, be nice if getting screen shots was as simple as plugging in an Android mobile device, opening up GIMP, and snapping the shot. That, unfortunately is not the case. Instead, the Android Software Developer Kit must be installed and used. But before the SDK can be installed and used, a Java dependency must be taken care of. For the sake of example, I am going to illustrate the installation and use of the SDK on an Ubuntu Linux 11.04 desktop (Kubuntu to be specific). Let’s begin this process.

Installation of the Pieces

The first piece of the puzzle to be installed is the Java dependency. For some Linux users, this will be the deal breaker — not because of any sort of overwhelming difficulty to install, but because of licensing issues. Unfortunately, Java is a must-have. To install Java on the Ubuntu 11.04 machine, we’ll need to add a repository. Thanks to the ease of APT, this task is made quite simple on Ubuntu Linux. To do this, follow these steps:

  1. Open up a terminal window and run:
  2. sudo add-apt-repository ppa:ferramroberto/java.
  3. sudo apt-get update.
  4. sudo apt-get install sun-java6-jre sun-java6-plugin sun-java6-fonts.

After the installation completes, run java -version which should return the version of Java installed on the machine. This returned information will look similar to:

 


java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
Java HotSpot(TM) Client VM (build 20.1-b02, mixed mode, sharing)

 

With the installation of Java complete, it’s time to start working on getting the Android Software Developer Kit up and running. The first step is to unpack and “install” the SDK. To do this, follow these step:

  1. Open a terminal window.
  2. From the terminal window, change into the directory housing the download.
  3. Unpack the archive with the command tar xvzf android-sdk_rXX-linux_x86.tgz (Where XX is the release number).
  4. Change into the newly created directory and then change into the tools sub-directory.
  5. Run sudo ./android update sdk which will open a new window prompting for the OK to run the update.
  6. Run the SDK update.

After the update has completed the process will prompt for the starting (or restarting) of the adb service. This must be OK’d or the SDK will not work. But once the adb service has restarted, it’s time to prepare the final configuration.

UDEV Rules

In order for an Android device to be recognized, a UDEV rule must be written for the device. The UDEV rules are files that inform the UDEV system of the device ID and allow communication between the device and the operating system. The rules are placed in /etc/udev/rules.d/ and look similar to:

SUBSYSTEM=="usb", ATTRS{idVendor}=="0bb4", MODE="0666"

The above rule is for a Droid Incredible. The key piece of the UDEV rule is the idVendor string (in the above rule, it’s “0bb4”) Other rules include:

  • 22b8 — Droid X and Xoom tablet
  • 04e8 — Samsung Captivate

If you are unsure of your vendor ID, the Using Hardware Devices page on the Android Developers site is a great place to find the vendor IDs for many mobile devices.

Figure 1

After the rule is created (name the rule something like 90-device.rules, where “device” is the make of the mobile handset) the UDEV system must be restarted. To restart this system, issue the command: sudo service udev restart. If, however, using the restart command does not allow the configured device to be seen, the machine will have to be restarted.

Connect and Shoot

It’s time to connect the device and grab the screen shot. Here’s how it’s done:

  1. USB Debugging must be turned on on the device (On some phones this is in Settings > Applications > USB Settings.)
  2. Connect the device via USB.
  3. Open up a terminal window.
  4. Change into the android-sdk-linux_x86/tools directory.
  5. Issue the command sudo ./ddms.
  6. Select the device from the listing in the Dalvik Debug Monitor (see Figure 1).
  7. Click Device > Screen Capture.
  8. Click on the Save button in the Device Screen Capture window (if the device screen is not ideal for the screen shot, make the change on the phone and then click the Refresh button on the Device Screen Capture window.)
  9. Navigate to where the screen shot should be saved and click OK.
  10. When finished taking screen shots, click the Done button.

If there is more than one Android device plugged into the machine, make sure to select the correct device before taking the screenshot.

That’s all there is to it (speaking with a hint of sarcasm). Of course, if the device is rooted, there are screen capture applications that can be easily installed. But for those non-rooted devices, taking screen shots is a fairly complicated process. Fortunately the quality of the final product is quite good and will be perfect for training, support, or just bragging.