Installing Android development environment on Ubuntu 9.04

I wanted to play with writing Android apps on my home Linux computer, which is currently running Ubuntu 9.04 (Jaunty Jackalope). These are mostly notes for myself, so don’t feel guilty if you skip this post. :)

- Make sure your system is up-to-date:

sudo apt-get update && sudo apt-get upgrade

- Install Java

sudo apt-get install sun-java6-jdk

- Switch Sun to be the default version of Java. It’s much faster than the built-in version, at least when I tried it.

sudo update-java-alternatives -s java-6-sun

- Make a directory, e.g. mkdir ~/android

- Download Eclipse from http://www.eclipse.org/downloads/ (I chose the “Eclipse Classic 3.5.1″ version). Move the code into that directory, then unpack it. Unpacking is enough–the software runs in place and doesn’t have to be installed onto the system other than unpacking it.

mv eclipse-SDK-3.5.1-linux-gtk.tar.gz ~/android
cd ~/android
tar xzvf eclipse-SDK-3.5.1-linux-gtk.tar.gz

- Download the latest Android SDK from http://developer.android.com/sdk/index.html and move it into that directory, then unpack it. I believe unpacking is enough–the software runs in place and doesn’t have to be installed onto the system other than unpacking it.

mv android-sdk_r04-linux_86.tgz ~/android/
cd ~/android/
tar xzvf android-sdk_r04-linux_86.tgz

- Edit your ~/.bashrc file and add a line to the bottom:

export PATH=${PATH}:/home/matt/android/android-sdk-linux_86/tools

Okay, now Java, Eclipse, and the Android SDK are installed. Now you need to install the Android Development Tools (ADT) for Eclipse.

- Run Eclipse. If you installed Eclipse in ~/android/eclipse then you can cd to that directory and run ./eclipse to start the program.

- Install the Android Development Tools (ADT) for Eclipse. Follow the excellent instructions at http://developer.android.com/sdk/eclipse-adt.html to get and install the ADT. Don’t forget the “Window > Preferences” step to tell Eclipse where the Android SDK is, so when you click “Browse…” you might navigate to /home/matt/android/android-sdk-linux_86 for example.

- Next, I installed a bunch of packages. In Eclipse, click “Window->Android SDK and AVD Manager.” In the resulting window, on the left-hand side will be an “Available Packages” option. I clicked on that, then clicked the checkbox beside the “repository.xml” package to select all available packages and then clicked “Install Selected.” 12 out of the 14 packages installed for me.

- Now you’re ready to create your first Android program . You’ll discover how to make an Android virtual device (AVD) along the way.

- If you want, you can get custom skins, e.g. a Nexus One skin for Android. You can unpack the .zip file in <your-sdk-directory>/platforms/android-x.y/skins/nexusone for example. Then create a new Android virtual device (AVD) and select the Nexus One as the skin.

- If you want to run your Android program on your own Android device, you’re pretty close. Follow step 10 of this walkthrough. When you’re done and the phone is disconnected from your Ubuntu machine, you’ll still have the executable, called an “android package” or .apk file on your phone. So you can show your friends your “Hello, World!” program. :)

Some resources that I found helpful (other than the official Android developer site) are below:
- http://www.futuredesktop.org/developing_android_apps_on_ubuntu.html
- http://www.softwarepassion.com/setting-up-android-development-platform-on-ubuntu-linux-904/
- http://www.howtoforge.com/installing-google-android-sdk1.0-on-ubuntu8.04-desktop
- http://androidforums.com/developer-101/2321-installing-eclipse-android-sdk-ubuntu-8-04-8-10-a.html
- You might also want to watch this O’Reilly video or some of the official videos.

If you found this post at all interesting, you might also be interested in Google I/O too. Google I/O happens on May 19-20, 2010 in San Francisco.

Doing the “Digital Cleanse”: no Twitter for a week

John Mayer had a good post about a “digital cleanse.” The idea is to step away from the busy, buzzy world for a week. John mentioned four ideas, but I’m going to try just one: “no use of Twitter or any other social networking site”.

That’s right, I’m going Twitter-free for a week. I don’t really use Facebook, so that’s not a problem. The only other social networking website I use is FriendFeed, so I’m cutting that out too. To keep me on track this week, here’s what I did:

  • Tweeted that I was doing the digital cleanse and changed my Bio line to mention that I was doing the digital cleanse.
  • Removed all Twitter apps from my mobile phone.
  • Removed the Twitter and FriendFeed shortcuts from Chrome’s new tab page.
  • Hard-coded a bunch of websites so that I can’t even access them. In Linux, you can type “sudo vi /etc/hosts” and add the following lines:

    127.0.0.1 twitter.com
    127.0.0.1 www.twitter.com
    127.0.0.1 facebook.com
    127.0.0.1 www.facebook.com
    127.0.0.1 friendfeed.com
    127.0.0.1 www.friendfeed.com

    What these lines say is “Computer, when you try to use the domain name system (DNS) to resolve twitter.com to an IP address, hard-code the IP address to be 127.0.0.1.” Note that 127.0.0.1 is a special IP address that corresponds to your own computer. In essence, these entries make it impossible to browse to Twitter, Facebook, or FriendFeed. You might need to reboot your computer too for the settings to take effect.

I’m thinking that I might blog a little more now that I’ve stopped tweeting for a week, so I’m doing one extra step–I’m linking my blog in Feedburner so that when I publish a blog post, it will tweet a link to that blog post. Here’s how to do it:
1. Log in to http://feedburner.google.com/ and click on your blog’s feed.
2. Click on the “Publicize” tab and then the “Socialize” service on the left.
3. Add your Twitter account and select the options you want. Here’s how it looks:

Tweeting from FeedBurner

Then click “Save” and that’s all you need to do.

So far, I’ve been Twitter-free for twelve hours. In that time, I’ve
- worked out
- taken down our Christmas tree, chopped it into sections and put it out on the street
- typed in three months’ worth of data for a project that I’m working on
- taken down our Christmas lights and packed them away
- stored all our various Christmas decorations
- run a couple loads of laundry
- put out the trash
- gone shopping and had a couple meals with my wife
Oh, and written a blog post. We’ll see how the digital cleanse works for the rest of the week. :)

30 day challenge for October: No Microsoft Software

In September I didn’t do a 30 day challenge because, frankly, I had a lot of work that I really needed to crunch through at the Googleplex and I didn’t have much spare time. But October is a new month, and so it’s time for a new 30 day challenge.

For October, I’m not going to use any Microsoft software. No Microsoft operating systems (WinXP, Vista, or Windows 7) and no Microsoft Office allowed. I will continue to use their keyboards, because they make very nice keyboards, and I will allow myself to use their websites–sometimes I need to do a query on Bing to test how well they do, for example.

I don’t plan to switch to Apple, although I might try a Mac for a week. Apple products are polished and usable, so why not switch to Apple? That would be a much longer blog post. Apple makes great design decisions for the majority of people, but if you don’t like a particular decision, it can be very difficult to change it. Have you ever wanted to see the exact time (including seconds) on an iPhone? It’s hard to do, and I’m that kind of guy. Another big reason is just that I’m huge believe in free and open-source software, and I want to support that sort of software.

So on Friday I installed Ubuntu on my Windows XP laptop. On Saturday, I downloaded all the data from my pedometer (the software only runs in Windows) and shut down my home Windows XP machine. I already had a machine running Ubuntu at home, but I managed to get it driving two out of my three monitors:

Ubuntu Desktop

What have I learned so far? The current version of Ubuntu (called “Jaunty Jackalope”) is really quite nice. There’s a lot of polish to the UI and the day-to-day tasks work very smoothly. At the same time, it’s possible to tinker around with something so much (I’m thinking about fonts right now) that you mess things up. But the dev version of Chrome for Linux has been really fast and stable, even though Chrome for Linux isn’t officially supported yet. I spend a large chunk of each day in a web browser, so having Chrome as an option was critical.

I’ll let you know how the 30 days turns out, but right now I’m optimistic. :)

Ubuntu 9.04 boots in 7.83 seconds!

Recently I treated myself to a solid-state drive (SSD). That’s essentially a hard-drive made out of memory chips. I bought the Intel X25-E Extreme, which uses faster single-level cell (SLC) memory chips instead of slower multi-level cell (MLC) memory chips.

I wanted to put the drive through its paces, so I decided to see how fast I could boot Ubuntu and start Firefox. It turns out that Ubuntu 9.04, code-named Jaunty Jackalope, is just a few days away, and one of the features listed is “significantly improved boot performance.” Perfect! I installed Ubuntu 8.10 from a CD and then followed the incredibly easy instructions to upgrade to the beta of 9.04.

So how fast did Ubuntu 9.04 boot with a solid-state drive? Really freaking fast. Like, “I can’t believe it’s already done” fast. Well, here, watch for yourself:

Total boot time from pressing power to Firefox loaded was about 22.5 seconds, with about 5 seconds of BIOS display on a Thinkpad. Subtracting out the Thinkpad BIOS display time, that means that Ubuntu 9.04 booted into Firefox in about 17.5 seconds. I think I’m going to have a lot of fun with this hard drive. Oh, and Ubuntu 9.04 looks really interesting too. :)

For the folks that are curious, I changed the GRUB boot loader time out from three seconds to zero, enabled automatic login to my account, then I added Firefox to default list of startup services.

Added: I collected a couple boot charts by using bootchart. As Ryan said in a comment, I ran sudo apt-get install pybootchartgui bootchart , then rebooted, then collected the image in /var/log/bootchart . If I’m reading the images correctly, it’s claiming 8.67 seconds for one boot-up and 8.69 seconds for the other boot-up.

Added: Okay, I reinstalled Ubuntu 9.04 so I could use ext4 and it shaved almost a second off the boot time! Check out this image which shows a 7.83 second boot time. :)

Trying (and failing) to get Ubuntu to work

I really want to run Ubuntu, but it shouldn’t be this hard. Plugging in an SD card reader that I picked up from Best Buy shouldn’t cause a hard freeze of my system (on both Gutsy Gibbon and Intrepid Ibex):

SD Card Reader

The card reader works fine in Windows. At this point, I’m honestly thinking about crashing the Ubuntu Developer Summit that will be held in December at the Googleplex in Mountain View, CA to pick peoples’ brains.

Okay, so Ubuntu freezes hard when you plug in the card reader (sometimes). Unless you report that bug, no one will know to fix it. So I’m trying to follow these instructions for debugging removable devices to do a good Ubuntu bug report, and finding that the instructions are pretty out-of-date.

For example, you’re supposed to kill, then start gnome-volume-manager in a foreground mode to see debugging messages. Except that the latest version of Ubuntu (Intrepid Ibex) doesn’t even install gnome-volume-manager. Oh, you can install it (and you’ll get the sound-juicer package with it). But when you try to run it, you’ll get this helpful message:

$ /usr/lib/gnome-volume-manager/gnome-volume-manager -n
manager.c/685: setting[0]: string: filemanager = nautilus -n –no-desktop %m
manager.c/690: setting[1]: bool: autophoto = 0
manager.c/685: setting[2]: string: autophoto_command = f-spot-import
manager.c/690: setting[3]: bool: autovideocam = 0
manager.c/685: setting[4]: string: autovideocam_command =
manager.c/690: setting[5]: bool: autowebcam = 0
manager.c/685: setting[6]: string: autowebcam_command = cheese –hal-device=%h
manager.c/690: setting[7]: bool: autopalmsync = 0
manager.c/685: setting[8]: string: autopalmsync_command = gpilotd-control-applet
manager.c/690: setting[9]: bool: autopocketpc = 0
manager.c/685: setting[10]: string: autopocketpc_command = multisync
manager.c/690: setting[11]: bool: autoprinter = 0
manager.c/685: setting[12]: string: autoprinter_command =
manager.c/690: setting[13]: bool: autoscanner = 0
manager.c/685: setting[14]: string: autoscanner_command = xsane
manager.c/690: setting[15]: bool: autokeyboard = 0
manager.c/685: setting[16]: string: autokeyboard_command =
manager.c/690: setting[17]: bool: automouse = 0
manager.c/685: setting[18]: string: automouse_command =
manager.c/690: setting[19]: bool: autotablet = 0
manager.c/685: setting[20]: string: autotablet_command =
manager.c/699: settings[21]: float: percent_threshold = 0.050000
manager.c/699: settings[22]: float: percent_used = 0.010000
manager.c/664: daemon exit: live and let die

It’s easy to find the source code of gnome-volume-manager online, but the relevant function is more cute than informative. Searching for ["live and let die" gnome-volume-manager] finds this post where someone tries to guess what the message means:

Fedora no longer uses gnome-volume-manager to auto-mount removable media — it’s now built into Nautilus. I am guessing that “live and let die” means “hey, someone else is already managing this” but that is pure speculation on my part. So if you get that error message it just means that you shouldn’t have been running it in the first place.

With that clue, you can go back and find this thread where Ubuntu developer wgrant helpfully lets someone know “gnome-volume-manager is no longer necessary either – nautilus does the mounting now.” It is good to find an Ubuntu developer posting answers online. But now I’m not sure how to generate Nautilus debugging logs akin to the gnome-volume-manager logs that fellow Ubuntu folks could use to debug the hard freeze. At least I do know how to generate udevmonitor logs using the new udevadm program.

Please pardon the melancholy tone. It’s just frustrating that plugging in an SD card reader can cause sporadic freezes on my Ubuntu computer. And if you plug in the SD card reader often enough, you may corrupt your system. I do see progress from Hardy Heron to Intrepid Ibex with several annoyances fixed, but there’s still a way to go.

Update: If any Linux/Ubuntu folks want to dig into it, I put all the log files I could think of at http://www.mattcutts.com/files/sandisk/ for folks that want to check it out.

css.php