Some Gradle Tips for your Android development

As most of you know, Android released the beta of their new IDE called Android Studio (Check the Google I/O session to see why it is so much better that what you are currently using). With it comes the new Android SDK Build System (Same deal, here is the corresponding Google I/O session).
It was released a few weeks ago at Google I/O and it’s just awesome. A little more work that the current build system but so much more possibilities offered to us developers :)

The new build system is based on gradle. You can use it partly from Android Studio but as it’s often the case you may have to use it from the command line to do more complex tasks. Here are some tips if you use it from the command line.

For example to compile your project, you have to use gradle assemble. But you can also just write gradle a.
As long as there is no other task sharing the part you write after gradle, it will autocomplete it for you.

gradle check can therefore be reduced to gradle ch. You can’t reduce it to gradle c however as there is also gradle clean which also starts with a c

Ok. That’s a good start. But let’s make it even better.

Open a terminal and try the following command
$ g (Just a ‘g’, nothing else)
You should get the following output:
-bash: g: command not found
If you already have a command called g, you can use gr or gra instead

If that’s the case, go to your .bashrc file and add the following line:
alias g='gradle'

Open a new terminal so that the .bashrc is read again with the new line.
Now you just have to write g a

In 5 minutes we jumped from gradle assemble to g a

You still want more tips ?!
The gradle completion is camelCase based. Which means gradle deviceCheck can be reduced to g dC !

(Thanks +Xavier Ducrohet for showing me the completion part of these tips ^^)

Similar Posts:

  1. You can always use “source ~/.bashrc” to rerun the config file within the current shell environment and thus use your changes immediately – or since you’re prefering brevity, simply use “. ~/.bashrc”.

Leave a Reply

Page optimized by WP Minify WordPress Plugin