Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ


Choose your language

InfoQ Homepage News Groovy 2.4 Released, Brings Full Android support

Groovy 2.4 Released, Brings Full Android support

Guillaume Laforge has released Groovy 2.4, bringing with it full Android support.

Head of Groovy development, LaForge says with the new Android support Groovy is being opened up to a wider range of developers.

Speaking to InfoQ, LaForge elaborated:

We're hoping Android developers will be happy to see their code being streamlined thanks to our various language shortcuts, and our closures that are helping to get rid of the verbose anonymous inner classes plaguing the Android SDK.

Going forward, we're interested in applying the same boilerplate-killer attitude towards simplifying the development of Android mobile apps with Groovy.

To that end, there's a community project called SwissKnife, offering several Groovy code transformations that will allow developers to focus on the business at hand rather than on that boilerplate technical code (handling UI vs background threads, dealing with event handling, with "parcelable" entities, etc).

Cédric Champeau, author of the static compiler for Groovy, in his June 2014 blog post introduced Groovy on Android and demonstrated how Groovy can be used to reduce the verbiosity of Java on Android with the example of Asynchronous tasks.

To parse a JSON feed, and then update the UI accordingly, in Groovy a developer needs to only write:

public class FeedActivity {
    TextView mTextView


    void updateFeed() {
    	Fluent.async {
            def json = new JsonSlurper().parse([:], new URL('http://path/to/feed'), 'utf-8')
            json.speakers.join(' ')
        } then {

Because Google has also settled on Gradle for build automation, to build Android apps with Groovy support developers will also be able to use the Gradle Groovy Android plugin.

In the Groovy 2.4 getting started guide, more information is given on the Android support.

It says:

It is possible to write an Android application in Groovy. However, this requires a special version of the compiler, meaning that you cannot use the regular groovyc tool to target Android bytecode. In particular, Groovy provides specific JAR files for Android, which have a classifier of grooid.

Other notable improvements to Groovy in 2.4 relate to performance, including efforts to "reduce the quantity of bytecode produced, to lower memory consumption of internal data structures, and fine tune bytecode for better performance."

Groovy 2.5 promises for developers improvements to the dynamic runtime, updated grammar with a newer parser, and support for some Java 8 features. LaForge says the most visible aspect is the Java 8 support, and the decisions around which features of Java 8 to support.

The Groovy team worked with the New York Times dev team to refine Android support, and it has been announced the next New York Times Android application will be based on Groovy and RxJava.

As reported by Victor Grazi for InfoQ on January 19 ("Pivotal Pulls Groovy/Grails Funding") the Groovy and Grails teams are still looking for new homes and sponsors. While LaForge says development on Groovy will continue, he notes that  it will likely evolve at a slower pace, with the team only able to work on it in their spare time.

Any InfoQ readers who would like to support Groovy, are encouraged to reach out to their managers and CEOs to see if their companies would be interested in funding the development of the Groovy project.

Rate this Article