Thursday, August 28, 2014

make-android - Android bloated build system be damned!

Lately I've been working on some Android stuff.  I hadn't worked on android in awhile so I downloaded their new android studio instead of the eclipse ADT.....

Ya I know it's in beta, but are you kidding me?  A sample hello world application took like 30 seconds to build with gradle.  And gradle itself is a bloated tool.  As soon as I attempt to type

$ gradle

in terminal it makes my macbook pro sound like it's taking off into space.

So I tried going back to the ant system in ADT. There I ran into problems as the AndroidManifest.xml now lives in a different place. I tried to look and fix the 1500 line xml garbage under

$ANDROID_HOME/tools/ant/build.xml 

and quickly said WTF.

Then I said you know what I am not going to live like this.  Screw you Google, your build tools are bloated abominations I will make my own.  It turns out that building for android without all the abstractions of gradle and ant is WAY faster and to me more elegant.

The native tools 'aapt' and 'dx' helps us here.


$ANDROID_HOME/build-tools/x.x.x/aapt
$ANDROID_HOME/build-tools/x.x.x/dx


So here is a example using good old Makefile. Yes I know I could of used ant to have incremental builds, but I can do the same in make (future post) without having to spawn a new jvm instance!

https://github.com/asharif/make-android

A lot of it as you can see is to support google play services. I can't believe Googles way is to add a project in eclipse! Anyway a gradle project that took 1 minutes to build on my late 2013 Macbook Pro now takes 7 seconds. That and my laptop doesn't turn into hot coal. Also notice how I left out the part about the keys,keystore and signing. I figure that stuff is outside the scope and regular java stuff.

Enjoy!

Saturday, March 29, 2014

ref: The CLI refactoring tool

So one of my coworkers tried to bully me into using Xcode for modifying files. I'm no longer a fan of IDEs like I was in years past so I politely declined as I have vim setup with NERDtree and CommandT. The only thing that I still have to use an IDE for is really java. Especially Java code that I didn't write myself and is ultra verbose with pyramids of class hierarchies to write the most trivial programs!  Regardless, this person who shall remain to be unnamed, insisted and pointed to the refactoring option of Xcode and other IDEs as a huge time saver.

At first I got annoyed.  Why are u forcing your style on me I thought to myself!  Then I realized to my own dismay that he was right.  I didn't even bother telling him I could do something kinda sorta similar with some combination of sed, find and grep.

I then decided to do something about it and ref was that something.  Not sure if I like the name but who cares lol.  Check it out @https://github.com/asharif/ref

Here is a sneak peak!