Update: looks like you can use gradle 1.4 now. These instructions were only required if you use “classpath ‘com.android.tools.build:gradle:0.2’” inside your build.gradle file. If you use the 0.3 version of the android plugin, these instructions are not necessary. These instructions might be useful as an example of how to downgrade something using brew, however.

I’m not much of a GUI person, but the Android community seems very committed to Eclipse. As a long time Emacs user, this does not work for me. I probably just need to spend more time with it, but it makes me wince that when I try to debug something using Eclipse, if I am in the wrong directory within the package explorer, I cannot debug my application. Eclipse seems to think that if I have selected the AndroidManifest.xml file, that I am trying to debug it, rather than the Android project with which is is associated. Oh well.

I have things working with ant as well. But, Ant uses XML, which is an unreadable pox on humans who are trying to communicate and collaborate with our computer friends. Aside from my long time handle, I don’t trust anything that begins with X. Xylophones are of course vastly inferior to the organic sounds of the Marimba. Xenophobia is one of the biggest challenges the world faces. The list goes on and on.

So, I was happy to see information about gradle, a new build tool, which the Android team seems to be standardizing around. Gradle uses a nice DSL, and looks to have lots of goodies for automating builds with libraries and free/paid apps. It looks clean and has the power of java snippets without the cruft of XML.

The documentation is very lacking, as of yet, and it does not look like the Google Group has much activity. I imagine the Android team will be chiming in more often there and on Stack Overflow as time goes on. Everyone is probably getting worried about looking bad at I/O.

One issue I found was that you cannot use the most recent version of gradle in the brew repository. You need to use 1.2 instead of 1.4. To do this you have to use a few git commands. I was surprised brew does not make this easier to do, but oh well.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
% cd /usr/local/Cellar/  # Go into the brew git repo
% brew versions gradle # Show the list of versions for gradle
1.4 git checkout 0b7303a /usr/local/Library/Formula/gradle.rb
1.3 git checkout c259bda /usr/local/Library/Formula/gradle.rb
1.2 git checkout 9b7d294 /usr/local/Library/Formula/gradle.rb
1.1 git checkout 7941972 /usr/local/Library/Formula/gradle.rb
1.0 git checkout dff67fb /usr/local/Library/Formula/gradle.rb
1.0-rc-3 git checkout 5f9e348 /usr/local/Library/Formula/gradle.rb
1.0-rc-2 git checkout f72e33f /usr/local/Library/Formula/gradle.rb
1.0-rc-1 git checkout e2438cf /usr/local/Library/Formula/gradle.rb
1.0-milestone-9 git checkout c27c667 /usr/local/Library/Formula/gradle.rb
1.0-milestone-8a git checkout 69eb948 /usr/local/Library/Formula/gradle.rb
% git checkout 9b7d294
% brew unlink gradle
% brew install gradle
=> Downloading http://services.gradle.org/distributions/gradle-1.2-bin.zip
######################################################################## 100.0%
/usr/local/Cellar/gradle/1.2: 98 files, 37M, built in 23 seconds
Chriss-MacBook-Pro-2:Cellar xrdawson$ gradle --version

------------------------------------------------------------
Gradle 1.2
------------------------------------------------------------

Gradle build time: Wednesday, September 12, 2012 10:46:02 AM UTC
Groovy: 1.8.6
Ant: Apache Ant(TM) version 1.8.4 compiled on May 22 2012
Ivy: 2.2.0
JVM: 1.6.0_41 (Apple Inc. 20.14-b01-445)
OS: Mac OS X 10.8.2 x86_64
% git checkout master
% gradle -v
% brew switch gradle 1.2
% brew switch gradle 1.4 # Switch to the newer version
% brew switch gradle 1.2

So, basically, go into the git repo, find the correct SHA commit, check that out, unlink gradle using brew, reinstall gradle to the older version, then checkout master, and you can then switch between the new and older versions.