If you are a ChromeBook user and a Android developer, the release of crouton takes the ChromeBook from a great pure browsing device into the world of no compromise powerful development machines, without dual-booting! Crouton makes the ChromeBook a creation device, not just a consumption device.
In addition, because my ChromeBook includes free 100MB/mo Verizon cell service, a kick-ass keyboard, a 10 hour battery, and is super light, all of a sudden this machine looks like a better machine than my MacBook Pro, which incidentally, cost 6.66x as much (2700 % 405, proof positive the MBP is the work of the devil!). I can now carry around a fully functional laptop with a great keyboard, develop from anywhere and be on a network from anywhere, wifi or none.
Here are the steps to turn this machine into a fully functional Android development machine. You’ll have a full Java SDK, Android SDK and be able to push apps from your ChromeBook to your Android device plugged into the USB. Wow.
- turn on developer mode (and note instructions depend on your ChromeBook version). You’ll probably need to create a USB recovery disk from a spare 4GB drive you have. You DON’T need to set this machine up to dual boot, just turn on developer mode and restore the device.
- Download crouton. I found some discrepancies in the instructions which could be due to my ChromeBook version, so compare and contrast with my instructions here if you need it.
- Enter the chrome shell: Type ctrl-alt-T to get into “crosh”. Then, type “shell” to enter a real BASH shell.
- Run crouton via x11/xfce by typing “sudo sh -e ~/Downloads/crouton -t xfce”. This will take a while as you are now installing a full Ubuntu XFCE system. You’ll be asked to create a user and password, and you’ll need the username and password later when you run things as root via sudo.
- Open a terminal by clicking on the terminal icon at the bottom of the screen.
- Install the JDK: either openjdk with “sudo apt-get install openjdk-7-jdk” or download one from Oracle and put it in the path (I placed it in /usr/local/jdk1.7.0_15/).
- From back in ChromeOS (you can get there by hitting ctrl-alt-Backspace, and go back to XFCE by ctrl-alt-Refresh), visit http://developer.android.com/sdk/index.html and download the android SDK. When you are in the chroot, the “Downloads” directory is linked to the chroot so you can see all files downloaded from your ChromeOS in the linked folder there within the chroot.
- Once downloaded, unzip the SDK, move it to /usr/local (or where ever you want) and then add to your path. I moved it using these commands:
sudo mv adt-bundle-linux-x86-20130219 /usr/local/. sudo ln /usr/local/adt-bundle-linux-x86-20130219/ /usr/local/adt</pre> I then added these to the end of my .profile file, extending the path to have the android tools, and then also adding ANDROID_HOME:
PATH=/usr/local/adt/sdk/platform-tools:/usr/local/adt/sdk/tools:/usr/local/jdk1.7.0_15/bin:/usr/local/gradle-1.4/bin:$PATH ANDROID_HOME=/usr/local/adt/sdk ``` Once you've changed profile, you might need to source it to take effect using the command `". ~/.profile"` * From the terminal on XFCE (return to XFCE using ctrl-alt-Refresh), run "android" and install which ever Android targets you need. This requires X11, so you'll need to do this from within XFCE. But, this will be the last time you'll need to run X. Unless you want to develop using eclipse, which is possible, but will stress out your resources a bit more. If you don't want to use Eclipse to develop, you can exit the XFCE session, which will take you back to ChromeOS and you can do everything from within the command line interface. * I had trouble with USB, but it might have been my confusion initially about connecting to USB as root (noted below). If you see issues where you cannot access the USB device, you might need to remount the USB filesystem (part of /dev) as read-write. To do this, open another crosh shell (ctrl-alt-T) and enter "shell". You can then remount the USB drive as read-write using the command "sudo mount -t remount,rw /dev /usr/local/chroot/precise/dev" * From here on out, everything can be done within a CLI (command-line-interface). Boot into the Ubuntu system from within the bash shell on crosh using this command: "sudo enter-chroot" You are now in the chroot without a heavyweight X11 process. * Adb needs to be started initially as root so it can find to the USB device. Run the command sudo `which adb` start-server. If it is already running, do "sudo `which adb` kill-server", and then run the command above). Once it runs as root, then you can connect via the port from any user process, so this only happens the first time you start ADB. * If you want to use Eclipse, skip to #16. If you want to use gradle, the new Android command-line friendly build tool, then install gradle. You cannot install gradle using apt-get, as the repository version is an older version which won't work correctly. Download the latest package from [gradle](http://gradle.org), unzip, and then move the files into /usr/local and add to your path (the .profile file above has the way I did it). * I don't recall where I found these gradle Android samples, but I [posted them here](http://vivoh.com/gradle-samples-0.3.zip) for you to play with. Download them if you want to play with gradle. * Jump into the gradle-samples-0.3/basic directory and then run: "gradle installDebug". You'll then see the "_Test-Basic" app running on your Android phone! Yippee! * If you want to use Eclipse instead, you'll need to run from X11. From shell, "sudo enter-chroot -t xfce" Switch back to chromeos using ctrl-alt-Back. Switch to xfce using ctrl-alt-Refresh. I had some nasty repaint issues where the XFCE window froze completely, requiring me to restart XFCE completely, but YMMV. I've not had any issues when running inside the CLI. Extras: My [ChromeBook](http://www.amazon.com/gp/product/B009LL9VDG/ref=as_li_qf_sp_asin_il_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=B009LL9VDG&linkCode=as2&tag=webiphany-20) has only 16 GB of SSD for the HD. I wanted to see what was left over after installation of my chroot. You cannot do this within the chroot (normally you could just type `df -h` to get this information). But, you can from within the ChromeOS shell: df -h. This is what I have after installing jdk, two versions of Ruby via RVM, a bunch of packages for some other projects, etc. I still have 2.5GB, which is plenty for a me to play with. When I previously setup my machine as a dual-boot, I was constantly stripping out packages to fit within a largish partition I made (I think I used all but 4 GB for the ChromeBook OS itself). This way, I can use all the space available, and if I need to recover, just delete the chroot and find a smaller distro, but won't have to repartition or anything messy like that. chronos@localhost / $ df -h | grep sda1 df: `/home/.shadow/d3cf1c07e07f9f4d3bf1dff10b98b0ca1fbd4c96/mount': Permission denied /dev/sda1 11G 7.8G 2.5G 76% /mnt/stateful_partition /dev/sda1 11G 7.8G 2.5G 76% /home /dev/sda1 11G 7.8G 2.5G 76% /usr/local /dev/sda1 11G 7.8G 2.5G 76% /usr/local/chroots/precise
One big question: is the performance of the ChromeBook
worth it when using it for this purpose? Timing information here for building the basic item in the gradle samples. This is far from a perfect performance test because the java interpreter startup time is lumped in with the time spent compiling.
Total time: 36.253 secs real 0m36.612s user 1m10.869s sys 0m2.468s
MacBook Pro with 16 GB of RAM, 2.7 Intel Core i7
Total time: 5.167 secs real 0m5.286s user 0m10.197s sys 0m0.704s