Intro
Sometime ago, i built some easy android-app to read RSS feeds and post something on a provided url. Basically, i already knew how to build an android application using eclipse. But that just a start! Real android-apps-development, involving on several libraries and it takes hours to resolve required dependencies without a tools to work on resolving those dependencies. Either you lost on finding the dependencies required or your apps getting too big when your apps ready to use. That's why MAVEN comes in hand.
Why MAVEN ?
Maven had the technology to split your application into several libraries and adding dependencies unto those libraries. That way, you won't be confused or lost in space when trying to note down your application dependencies. That's why maven should be REALLY considered when you building a large application. Well, what i mean large is an application which is more than hello world :-D
Preparation
Downloads
Installing
- Install / Extract Java, and set your JAVA_HOME environment
- Extract Eclipse
- Install Maven (I'm working another post for guidelines on installing maven)
- Install Android-SDK (I'm working another post for guidelines on installing Android-sdk)
Configure
- Configure Eclipse
- Install m2e
- Install m2e-android support
- Point maven into local installation directory
- Install Android AVD and download required emulators and runtime
- Set's up Android default runtime
- Testing your maven installation
Create My First Android Project
Create New Android Application Project
Right click on project workspace -> New -> Android Application Project
- Fill Up :
- Application Name
- Project Name
- Package Name
Choose
Build SDK
Minimum Required SDK
- Next
- Next

On this screen we fill up the first activity we have on our new android application
Fill Up :
- Activity Name
- Layout Name
- Click Finish
Mavenize Project
- Fill up :
- Name
- Description
- Copy-paste this following text to Pattern
4.0.0
org.someapp.somename
someapp-android-somename
theAppVersion
the-app-artifact
apk
the-app-name
- Choose New XML within Context
- Click OK
- Click OK
- On root of your project, right click and then choose New -> Other -> XML -> XML File
Give your new XML File name : pom.xml
Choose Template Name that you've defined earlier on step 1 (one) - Modify your pom.xml file
- <parent> tag
Change value on tag :org.someapp.somename someapp-android-somename theAppVersion
- groupId : into application group id (ex: org.mycompany.myapp)
- artifactId : into application artifact id. (ex: myCompanyApp.myFirstApp)
- version : Application Version (ex: 1.0.0) - <artifactId> tag
Change value on tag :
- artifactId : into application artifact id. (ex: myCompanyApp.myFirstApp) - <name> tag
- name : into application name (ex: myFirstApp) - <properties> tag
add project dependencies before </properties> tag. Several required properties for this tag are :
com.google.android android ${android-version} provided
org.springframework.android spring-android-rest-template ${spring-android-version} - You are set and done just try to run mvn clean , mvn install, mvn android:deploy