Live Blog: Groovy Android programming

This blogpost will keep track of our current progress on our effort to make Groovy run on Android phones. Instead of creating a summary like in the previous ‘This Week in Discobot’ posts, we will update this blogpost every half an hour!

Erik (20:36): after a nice dinner, we make a small plan for the evening. Marcin will work on committing and pushing the Gradle Android plugin into our Github fork, while my plan will be to continue to build a small Android application which will run the entire Groovy testset on Android, to assure our code works as we expect it to work.

Marcin (21:39): Erik created a small test program which successfully runs the Groovy unit testcases using the AllTestSuite. Next plan is to extend that so it also works on the Jar, so classpath scanning needs to be implemented.  I the meantime, I worked on the way that intermediate files are organized in the Gradle Android Plugin and I added a test to verify signing the APK with the Android debug key works.

Erik (22:14): Investigating Reflections to use as a classpath scanner in Groovy

Erik (23:19): One hour later, still little success with the classpath scanning. Some testfiles aroud found, some aren’t, and doing a ‘reflections.getSubTypesOf(GroovyTestCase.class)’ currently returns an empty list. Not what I expected.

Marcin (23:37): I’m done with all the changes I wanted to do on the Gradle Android plugin. Now I’m writing the first integration test for the Gradle Discobot plugin. As I’ve never done this before for a Gradle plugin I’m using integration tests from the Gradle Android plugin as an example on how to do it.

[nggallery id=3]

Erik (0:58): After hacking around with the reflections project with Marcin, it’s time to call it a night. We got the classpath scanning to work now, but with a little bit more troubles than expected. Wrote an email to the authors of Reflections to ask them if they can explain some of the choices they made.

Good night everyone, and thanks for reading!

This (two)week(s) in Discobot (27-28.2011)

We continued our work on getting Groovy working on Android over the past two weeks.

Erik has made quite a good progress with the tests suite for Discobot. What he has achieived by now now is a slightly modified original Groovy test suite running against the compiled but not packaged (jared) code of our patched version of Groovy on his laptop. And of course it’s all green! As we removed some unnecessary classes and had to patch other, because the Dalvik VM doesn’t provide all the classes that regular Java does, Erik also had to remove and change some of the tests but we are trying our best to keep the needed patching to a minimum. It all looks promising and the next step for Erik is to run the tests against a jar and then create an Android app that will run all the tests on the emulator/device. We need that to learn if the differences between Dalvik and regular Java will break any tests and we can do that only by running the tests on a real Dalvik VM. This will give us some confidence that when people start using Discobot for something more complex than a ‘Hello World’ app things won’t start to break big time.

One of the concerns when Hjalmar Ekengren started his first efforts to run Groovy on Android as his GSoC project was the performance. I recall him telling me that it took up to 20s to start even a really simple app back in 2009 in the emulator. Apparently the things have improved quite a lot and our simple ‘Hello world’ example loads in the emulator in less than 5 seconds. It’s still quite long in my opinion. But last week when I uploaded our test application to my HTC Desire running Android 2.2 I was really surprised how quick it loaded the app – I think it’s less than a second! So we don’t have to worry about the performance, at least at this stage of the project.

For the past two weeks I worked hard on modifying the Android Gradle plugin and creating the Discobot Gradle plugin. Thanks to the extensive documentation that the Gradle project has and a terrific example in the original Android Gradle plugin it wasn’t hard to understand Gradle concepts. And when you get the main principles of Gradle it’s a real pleasure to work on a Gradle plugin.

I’m basically done with all the changes that had to be made to the Android Gradle plugin so that the Discobot Gradle plugin could extend it and use it for its own needs. The last thing I need to work on is the documentation – the changes I’ve made are breaking for the Android Gradle plugin and I think that if I update the docs the developers of that plugin will be happier to accept my pull request. I tried to contact the github repository owner of the Android Gradle plugin (Jason Voegele) before I started the work on it to learn what is his view on the changes I planned to make but unfortunatelly I didn’t get a response to my email. Hopefully when I create the pull request someone will get it processed…

Also the Discobot Gradle plugin is almost ready. Currently it builds the Android projects that use Groovy without a problem. I still want to add one task to it that will create the project structure and default files (AndroidManifest.xml and the main activity class among others) so that it will be easier to start the project from complete scratch with only a build.gradle file in your project. The task, updating Gradle Android plugin’s documentation and creating a pull request on my changes are my goals for the next week.

This week in Discobot (26.2011)

Currently, we (Erik Pragt and Marcin Erdmann) are working on getting Groovy to run on Android and make the process as smooth as possible for other developers. On this blog regular updates will be posted to inform you about the progress we made, the problems we ran into and how we solved them. This is the first episode of ‘This week in Discobot’. Read more