Thursday, February 28, 2013

Building Android application with Maven -- Unknown packaging APK

Should have been an easy thing. However, I spent my own 15 minutes because of not following rules. So here they are for starting up with maven and android:

  1. Read the Getting Started here
  2. Create your own pom.xml, copying one from one of the samples. Samples can be downloaded also from Google code:
After performing these steps, I was unable to proceed, unfortunately. I had an error from maven build saying that my pom is not correct - looks like it did not pick up the android plugin, and thus did not understand the apk packaging. 

Unknown packaging: apk @ line 15, column 16

So i started lurking around and got the difference soon. I missed a single line in declaring a build plugin. Without the element, maven is not picking the new packaging. Oh, and also - the plugin requires maven 3.0.3 or newer. 

This is my entire Build section:

Build/plugins section:
Dependencies section:


Richard Kennard said...

This blog entry would be a lot more useful if you actually posted the 'missing single line' instead of just alluding to it :)

The missing line is: <extensions>true</extensions>. This tells Maven to load extensions (such as packaging and type handlers) from this plugin. This is what enables the 'apk' packaging type.

Alexander said...

Thanks Richard; I wonder if I just missed it. I'll have the article corrected.

And sorry for letting such an obvious thing out of scope.