Sunday, January 15, 2012

Update: GUIs, Here's How They Work

So here's an update to a recent post : Android recently released their design guidelines for Ice Cream Sandwich. It can be found here. Some interesting things to note:

The design principals are abstract and lofty. Things like "Enchant Me", "Simplify My Life", and "Make Me Amazing" are pretty open to interpretation, but at least it gives you an idea what the designers were thinking when they created the interface.

The Style section of the site describes things like how to design for different resolutions, what themes would compliment the native UI, their Roboto font, icons, and finally writing style

The writing style is most interesting to me. Here are their main guidelines.

  • Keep it brief
  • Keep it Simple
  • Be Friendly
  • Put the most important thing first
  • Describe only what's necessary and no more
It's interesting because most of the examples they used seem to have came from their older UIs. Maybe they have gotten things right with ICS. If you got the time, I would encourage you to check out their other guidelines -- it's in interesting read (if you're in to that kind of thing).

Wednesday, January 11, 2012

Linux and ADB

Hello all!
I thought I would post a little guide on what you have to do to get adb to work with eclipse and your device out on ubuntu.
This assumes:

  • You're running Linux as a normal user
  • You've installed the Android SDK
  • You've installed Eclipse
  • You've installed the Android SDK plugin for Eclipse
I did all of that and it worked wonderfully for the emulator, but when I tried to run it on my Nexus One, it wouldn't recognize it. Since I do linux for a living, I though I would do a short writeup on what was broken and how to fix it.
Lets begin with reproduction of the problem. I'll plug in my Android device with USB Debugging turned on. Then I'll go to a terminal and type:

user@server:~/Projects/android-sdk-linux_86/platform-tools$ ./adb devices
List of devices attached 
???????????? no permissions

Well that's no fun. Note: if I had the emulator running, it would find it just fine. Well lets take a look at what went wrong. To understand the problem we are facing, you must understand that in linux, everything is accessed like a file, and files have permissions. The adb-server was having issues reading the usb device and to fix that, we must find the USB device "file" and make sure the permissions are correct on it. Devices in linux are kept under /dev/, so after looking around there a bit I find it at /dev/bus/usb/001/106 
I can do the following

user@server:~/Projects/android-sdk-linux_86/platform-tools$ sudo chown user /dev/bus/usb/001/106
<enter password>
user@server:~/Projects/android-sdk-linux_86/platform-tools$ ./adb kill-server
user@server:~/Projects/android-sdk-linux_86/platform-tools$ ./adb start-server

And now when I list my devices

user@server:~/Projects/android-sdk-linux_86/platform-tools$ ./adb devices
List of devices attached 
HT9CRP801xxx device

Huzzah! But do I have to go through that song and dance each time I want to develop? NO!
You don't even have to resort to writing your own script! You can use a function included in most linux distributions called udev. udev is a program that is ran every time hardware changes on your machine. You have the ability to write "rules" to compare the new hardware against some parameters and if  they match, you can have it do some action, like call a script or set permissions on the newly created device files. All rules go into /etc/udev/rules.d/ . Lets take a look at the rule I created.

user@server:~/Projects/android-sdk-linux_86/platform-tools$ cat /etc/udev/rules.d/99-android.rules 
SUBSYSTEM=="usb", SYSFS{idVendor}=="18d1", MODE="0666"

Basically, make a file just like that one, but change the 18d1 to match your device. It's pretty straight-forward (uh...sure), but where did that 18d1 come from? It came from the output of lsusb

user@server:~/Projects/android-sdk-linux_86/platform-tools$ lsusb
Bus 001 Device 107: ID 18d1:4e12  

Mine had a blank description  but maybe other device would say something about adb in there to give you a hint. I know this isn't quite a step-by-step guide, but hopefully it helps someone out. Let me know in the comments if you get stuck.