Last Updated: January 28, 2019
·
3.658K
· vevmesteren

Android Development on Chrome OS

So earlier this year I went down the road of so many. I decided to give Chrome OS a whirl. With my new role in the start-up, though still a developer at heart, my time spent in code has become much less frequent. As long as I have a terminal and VIM to check in every now and then all was well.

My daily routine was more spent in emails, Hangouts etc. But this post is not about this evolution of my own everyday life, so enough about that part.

I did spend Two full months exclusively working on a 2013 Chrome Book Pixel (http://www.theverge.com/2013/2/25/4023830/google-chromebook-pixel-review). Now, people can say what they want about the utility of this overpriced marvel, but remains just that, a marvel. Even when two years old, the Laptop still felt great to work on. In short Chrome OS is an awesome operating system, mostly because is crazy fast to load and when you install an App, it’s synced with your Google Account, so when you go on your office Windows, Mac or Linux PC, as long as you have Chrome 99% of the application works and gets downloaded automatically. I am digressing, this post is not about Chrome OS.

What I did want is to continue to be able to code, and work locally, when needed. My normal dev toolset revolves a lot around Vagrant/Ansible (http://jeto.io) and Python, PHP and Node.js. Having VIM and Some Sublime Text like editor around is really all I need.

Whilst I am back on my regular Ubuntu Laptop when at the office now, I have continued with Chrome OS when at home. And since a couple of weeks I wanted to see if I couldn't push this a little further.

I have been playing a bit with Android Development as of late. More specifically, using Cordova to do so.

So last night I wondered, can I do this on my Chrome OS laptop as well. And it turns out, I can. So here it goes.

The first thing you need to do is to switch your Chromebook to Developer mode (https://www.chromium.org/chromium-os/developer-information-for-chrome-os-devices/chromebook-pixel) it depends on the Chromebook your on, but it's a pretty straight forward operation, which I won't get into now.

First Chrome App pre-requisites
"Secure Shell": https://chrome.google.com/webstore/detail/secure-shell/pnhechapfaindjhompbnflcldabbghjo
"Crosh Window": https://chrome.google.com/webstore/detail/crosh-window/nhbmpbdladcchdhkemlojfjdknjadhmh

Next you want to head over to install Crouton (https://github.com/dnschneid/crouton).

Fire up the Crosh window

shell
sudo sh ~/Downloads/crouton -r trusty -t cli-extra 

Once your Chroot is up and running enter it with

sudo enter-chroot 

I can’t recommend TMUX (or something like it) more then enough, as multiple Terminals are your friend throughout your life in the Crosh Window. VIM is again my own preference you choose your poison for your favorite editor here.

So my first command installs some base tools and a few packages we’ll be needing later on.

sudo apt-get install tmux vim software-properties-common wget curl ant libc6-i386 lib32stdc++6 lib32gcc1 lib32ncurses5 lib32z1 lib32z1-dev git 

Next we need to prep the machine to work with Android. That requires Java, I’ll go for version 8, again choose your poison here…

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
sudo apt-get install oracle-java8-set-default

make sure you’re all set with

java -version

Ok, the basework is done, now let’s go get the Android SDK. Head over to https://developer.android.com/sdk/index.html#Other to get the latest URL to the SDK. To download it run

cd Downloads
wget http://dl.google.com/android/android-sdk_r24.4.1-linux.tgz

Next up unpack the package

sudo tar zxf android-sdk_r24.4.1-linux.tgz -C /opt/

Now, to be able to make use of the Android goodie bag, you need to add it to your .bashrc

vim ~/.bashrc

and append this to the end of the file:

#ANDROID SDK 
export ANDROID_HOME="/opt/android-sdk-linux"
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/platform-    tools

Save and Exit

For the changes to bashrc to take effect run

source .bashrc

To make sure that root can run android and adb functions, install the allimportant sdks etc

sudo chmod 0777 -R /opt/android-sdk-linux

Congratulations you are now ready to run Android commands on your Chromebook. Have a Debug Enabled Android device floating around, go ahead and connect to your Chromebook USB port, and you will find that adb devices will see it. So now you can already sideload, install, flash and all the glorious Android Hackery you expect. Not all bad, but for not quite what we want. We want to build and deploy our own Android apps, so let’s continue...

Next up we need to install the SDKs and Tools we’ll be using, to create a basic hello world cordova Android App we’ll be needing Android 5.1.1 (API 22) platform SDK, Android SDK Build-tools version 19.1 or higher and the Android Support Repository (Extras). To list all available packages run

android list sdk --all

Woooha, that’s a load of packages to read through in the console, so let’s filter them like so, respectively

android list sdk --all | grep "5.1.1"
android list sdk --all | grep "19.1"
android list sdk --all | grep "Support "

Now that we know our IDs, we’re ready to install

android update sdk -u -a -t 16,27,144

Next up, installing Cordova. First things first, let’s go get a nice and fresh Node.js install

curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install -y nodejs

We’re now ready for Cordova goodness

sudo npm install -g cordova

And that’s pretty much it. From here on in, https://cordova.apache.org/docs/en/5.1.1/guide/platforms/android/ is your friend, but for the TL;DR; crowd.

Inside your working directory run

cordova create hello com.example.hello HelloWorld
cd hello
cordova platform add android
cordova build

or if you have an Android device attached

cordova run

And that....my friends...is how the cookie crumbles.

1 Response
Add your response

Thanks for share

over 1 year ago ·