I’m looking at some Android development at the moment in work after being immersed in iOS development for the last few years. Switching tools always has a bit of a learning curve and this post documents what’ve setup so far. I’ve had a few false starts so this might come in useful to someone else.
Since pretty much everything I do these days app wise involved consuming some sort of REST API, I went looking for a library to handle that end of things. I came across Robospice which at first glance fits the bill for what I want. It uses Maven for project and dependency management.
As I’ve not really used Java I’ve never used Maven in anger and had some difficult in setting it up properly. While there are instructions out there, they all assume some working knowledge of how Eclipse, Maven or the ADT works so not ideal for a complete beginner. There was a lot of googling and reading Stack Overflow before it finally all worked.
Here’s the steps I followed to get it running on my iMac:
- Download the Android SDK as the ADT bundle and install
- Set the environment variable ANDROID_HOME to point to the sdk directory
- Run ‘android update sdk –no-ui –all –force’ (android is under tools in the sdk folder. Also, this can take a while as it downloads everything)
- Open ADT and install the Marketplace Client via ‘Install new software…’ under ‘Help’
- Install Eclipse Plug-in Development Environment via ‘Install new software…’ under ‘Help’
- Install M2E Plugin via ‘Install new software…’ under ‘Help’ using the URL http://download.eclipse.org/technology/m2e/releases
- Install Maven 3 if you have an older version (or none) on your system (instructions on how to do so here)
- Install Egit from the Eclipse Marketplace
- Install Android Configurator from the Eclipse Marketplace (search for ‘android m2e’)
After all the restarts, you should be now at a stage where you can import Maven projects.
There’s a couple of more steps before you’re able to create a Maven project:
- Start creating a new Maven Project
- In ‘Select an Archetype’, click on ‘Add Archetype…’
- Set ‘Archetype Group Id’ to ‘de.akquinet.android.archetypes’
- Set ‘Archetype Artifact Id’ to ‘android-quickstart’
- Set ‘Archetype Version’ to ‘1.0.8’
You can then continue on creating your project. Once it’s created you may see the error “Project ‘skillpages-android’ is missing required source folder: ‘src/test/java’ “. This is a known issue and here’s two solutions to this:
- Create the directory and refresh the project
- Update the Android Configurator from the URL http://rgladwell.github.com/m2e-android/updates/master/
I will note that after I updated the plugin, it broke creating new projects for me. But I’m not sure if that was something I did or an issue with it. I ended up removing and reinstalling it.
Hopefully this will help someone else bootstrap themselves into Android development and not just left fruitlessly searching.
Thanks!, this is *by far* the best guide to integrate Maven with android and eclipse.
I have noticed that some steps dont behave deterministically: I had to start over to make it work.
One last thing: you need to have maven 3 installed AND android tools included in the path ( http://books.sonatype.com/mvnref-book/reference/android-dev-sect-config-build.html ), and I would do it first.
You really saved my life.
Awesome! Thanks
Did you have any issues with the gen folder not existing after creating a new Maven project from the archetype? The <a href="http://code.google.com/a/eclipselabs.org/p/m2eclipse-android-integration/wiki/GettingStarted" Getting Started instructions show a gen folder in the screenshot towards the bottom of the page, but I haven’t been able to get that folder to generate and have errors because it can’t find R.java. Thanks
I did but I think I just had to create the gen directory manually and refresh the project to get it working.
Oops, messed up the link. http://code.google.com/a/eclipselabs.org/p/m2eclipse-android-integration/wiki/GettingStarted
Thanks! Saved my life!
Thanks helped get me going on OSX 10.8 just fine. 🙂
comprehensive work!:)
thx a lot!
Thank! Awesome tutorial 🙂
**Issue**
– The issue is that Eclipse does not recognize the quickstart project as an Android project and R.java is not generated. What do I need to do?
**Software used**
– Eclipse Luna 4.4.0
– Android for Maven Eclipse 1.0.1
**Steps performed**
– create a new Maven project
– select android-quickstart version 1.1.0 archetype (de.akquinet.android.archetypes)
– I have to set eclipse to ignore the following in Pom.xml (lifecycle-mapping) since m2e-android does not recognize for some reason (Is this my issue?)
– consume-aar
– proguard
– generate-sources
– At this point I can successfully run “mvn clean install” from the command line, but Eclipse still does not recognize as and Android project.
I think your problem is you need to start off as an Android project and then convert that to a maven project rather than starting off as just a maven project. I don’t have eclipse installed on this machine so I can’t check for sure.