Project Development: Set up hardware device (Samsung Nexus S) for developping on Ubuntu 10.04+

Wednesday, March 23, 2011

Set up hardware device (Samsung Nexus S) for developping on Ubuntu 10.04+

The most of the steps are from official android develop link.

The time I tried my first Hello World Android application on emulator is Mar 2010, which is totally one year ago, but now I am still wandering around, even my heart beats always show me how I love android, and how deep I believe it's the trend of the future. However, I didn't make any progress, or make any individual application for the last year. There are so many reasons for this embarrassing result, but one of them, the very important one is I can't connect android phone with my Ubuntu system under debugging mode, even I tried a lot of ways.

Today, I finally solved this problem, here are the steps you should follow:

  1. Make your project as "debuggable". In the AndroidManifest.xml file, add android:debuggable="true" to the  element.
  2. Turn on "USB Debugging" on your android phone.
  3. Setup the system to detect your device.
    • Create new file as root: /etc/udev/rules.d/51-android.rules
    • Edit the new file: SUBSYSTEM=="usb", SYSFS{idVendor}=="18d1", MODE="0666"; #Here I tried to use Samsung's idVendor, but it's totally wrong.
    • Don't forget to save it.
    • Change the permission: sudo chmod a+r /etc/udev/rules.d/51-android.rules
  4. Here, I tried to restart the server by
    • adb kill-server
    • adb start-server
    But it doesn't work.Thus, I just restart my computer, and it works now.
  5. Break;
  6. Test your connection: adb devices, which is from SDK platform-tools/ directory.
    List of devices attached
    ##########       device
    The sequence of # is the serial number of your device.
  7. END;
  8. You could also check your USB connection:
    sudo lsusb -v | grep -C5 4e22
    Bus 002 Device 003: ID 18d1:4e22 
    Device Descriptor:
      bLength                18
      bDescriptorType         1
      bcdUSB               2.00
      bDeviceClass            0 (Defined at Interface level)
      bDeviceSubClass         0
      bDeviceProtocol         0
      bMaxPacketSize0        64
      idVendor           0x18d1
      idProduct          0x4e22
      bcdDevice            2.27
      iManufacturer           1 Samsung
      iProduct                2 Nexus S
      iSerial                 3 30308909D7B600EC
      bNumConfigurations      1
You could run your program, even Hello World on your Samsung Nexus S. now.
Hope this will be useful for other developer who is struggling with this problem.