Mavenizing Android: Adventures with Eclipse and Jenkins

I have written on Maven and Android about over a year ago. Since then a lot of things have happened: the Maven plugin for Android has advanced considerably, there are new Android versions, improved Android tools, an Android m2e connector and many other things.

When I went back to one of my apps to start programming on it again, I noted that my Android Maven build setup was not working anymore in Eclipse after a year of lying dormant. I also found that after a bit of re-factoring I had introduced a few bugs into my code. Not a big surprise since all my Android testing had been manual testing on a device or the emulator because the test setup that comes with Android was too complex for my experience in writing tests.

For my other coding projects I have set up Jenkins and Sonar to help me analyse the quality of my code and execute my tests all the time. I learned to enjoy the advantages of good test coverage and regularly executed builds. It was time to re-think my style of Android programming and testing.
Continue reading

Posted in android, development, processes | 1 Comment

Why Test Coverage?

If you haven’t tried to do something yourself, you will never be able to appreciate its advantages or disadvantages because there’s only so much you can learn from theory. So do whatever you talked about doing all the time …

Case in point: test coverage. We all know we should a) design for testing and b) write those tests.

Continue reading

Posted in development | Leave a comment

Spring & Restlet Integration: A complete example

This morning I started writing a Restlet Application that will, when it is completed, supply a restful api for my web application. The web application is already mostly done (not yet public, however there is a landing page and a few screenshots available at http://rpgtracker.de). The web application is written in Wicket (1.5) and uses Spring (3) for dependency injection and Hibernate as persistence layer. I went to great lengths to make accessing my domain objects in the database easy and remove as much boring boiler-plate as possible. So when writing the rest api, of course I wanted to re-use all the effort that went into creating easy-to-use database access. I also got used to the comforts of dependency injection that Spring provides – especially since in Spring 3 it is all annotation based! I had worked with Restlet (2.1) on a previous project and so it was my go-to implementation for a restful web service.

So much for the bullshit bingo – meant to say basic premise … now on to the real examples, because I did have a bit of trouble stitching it all together and maybe this helps someone out there solve the same problem faster.

Continue reading

Posted in development, java | 2 Comments

Java Memory Optimization & Server Resources

I’ve learned a bit about Java and also about Linux this past week-end. I finally found out, what it was that kept me from going forward with the deployment of my web application. I kept getting OOM errors when starting up a second java process on my virtual server. Even stackoverflow users, thorough and diligent as they are, could not provide me with a solution. (In the end it turned out however that one had provided me with the right information, he just could not know that I was unable to apply it, due to the configuration of the server.)

To begin here are a few quick notes on java memory usage and two nice articles: common errors and an overview of JVM Options:

Continue reading

Posted in development, java | 2 Comments

Automate your Android builds comfortably

Or: How to set up your Android app’s Multi Module Maven build as Eclipse project.

This week I spend a few hours searching for a solution for automated Android builds with Maven. I want to launch my first paid app with minimum fuss. There is a free version of the app on the market already and now I want to use a multi module Maven project to manage both a free and a paid version of the same app comfortably. I am a lazy programmer after all.

Since it was not quite the trivial endeavour I had hoped – but of course not expected – it to be, I decided to write this up as an article for myself and of course for all the other Android developers out there who don’t want to waste time setting up projects when they could be gold-plating their apps 😉

You are probably only reading this after you have already created your app and have everything running from Eclipse. And it works, too, up to a certain point. I only started on automated builds when it started hurting me to not have them. So I won’t cover setting up a fresh project. You should have some working knowledge of Maven and Android. I will assume you have both setup Android and Maven projects in the past.

This article assumes that you have an Android project without an automated build somewhere. If you don’t have one just create a new Android project in Eclipse, this will give you a HelloWorld app and everything that is necessary to follow the instructions in this article. Please don’t recycle your project, you can easily copy over your classes and resources later. Start from scratch with the setup until you have understood what is going on – there’ll be less crying if you don’t break your working project along the way. If you really want to do this on an existing project, tag now!
Continue reading

Posted in android, apps, development, work less | 5 Comments

A fairy tale of the Wicket and the Maven

Lately I’ve been working on several Apache Wicket projects. Wicket is quite an intuitive and well-rounded web-application framework. Well intuitive for someone who has been programming Java for a long time. Since for the moment I am back to using Real Java (as opposed to Android), I am also happily back to using Maven and that’s what this article is mostly about.

When starting out with a new technology I think it’s best to jump in and get started on a project. Because nothing teaches as fast as doing and nothing leaves the same lasting impressions as the mistakes you make.

The fastest way to introduce yourself to wicket is the Wicket Quickstart project. Here’s the commandline (you could also do the same by creating a project in Eclipse but I would have to provide screenshots and much more explanation, when the original page – see link above – does the same quite well).
Continue reading

Posted in development, java | Leave a comment

How to use the Android Camera

I have now spent quite a few hours programming for my next app which needs to take pictures. I did not want to use the camera app that’s already there for several reasons. So I need to programm my own. The API is not all that difficult to understand. Here’s the basic version of how to talk to the camera:

[sourcecode language=”java” wraplines=”true”]
//creating the camera object
Camera camera = Camera.open();
camera.setPreviewDisplay(getSurfaceHolder());
final Camera.Parameters parameters = findBestParameters(w, h);
camera.setParameters(parameters);
camera.startPreview();
final PictureCallback callback = new PictureCallback() {
@Override
public void onPictureTaken(byte[] data, Camera camera) {
try {
//async task for storing the photo
new SavePhotoTask(CameraView.this.ctx, data).execute();
} catch (final SavePhotoException e) {
//some exceptionhandling
}
}
};
//no need for shutter callback or raw callback, jpg callback is enough
camera.takePicture(null, null, callback);
[/sourcecode]

Doesn’t sound so hard? It only took me hours to get it right. Because I never got to the onPictureTaken(...) method. The callback never happend! I made the mistake wanting to do something else after taking the picture – who wouldn’t?
Continue reading

Posted in android | 5 Comments

Open Source Android: DroidWeight

A few minutes ago I made my first commit on the new svn repository for DroidWeight on google code: http://code.google.com/p/droidweight/.

I had a couple of requests to open source it. Since I never planned on making money from the app anyway – after all it is my learning app – I thought I could just as well share. Maybe I’ll find a couple of contributors.

So if you would like access to the repository and the google group just drop me a note via mail or the contact form and I’ll see to it.

Right now the documentation is practically non-existent, so you should be brave enough to find your own way through the code.

I’ll still be publishing releases as before only now everyone can see the code and take it to make their own stuff with it, laugh about dumb beginner’s errors I made or contribute patches.

This is the first time I am open sourcing a project of mine and I am curious how it will turn out 🙂

PS: the app is close to 10.000 downloads on the market!

Posted in android, apps | 2 Comments

Call for links

I am looking for pages, forums, communities and blogs on all things scrum or agile. I will also happily take a look at general software development processes and methodology sources. I’d be grateful for some good places to start reading.

What are your favorite places to go read up on the latest agile news?

Posted in Agile Methods, processes | 3 Comments

3 Approaches to Change

In Can you change your team? I asked you to think about what you want to change the most about your work. What you want to change dictates which approaches to change is most likely to succeed. The best approach depends largely on how much influence you have on that aspect of your work.

Analyse your problem

Now that you know what you want to change, it is time to start thinking about a solution. Most of the common problems can be sorted into three categories according to the most promising approach to get them fixed:

Posted in processes | Leave a comment