Building Android Project with Maven and Eclipse


Android, Maven and Eclipse, it appears to be best combination, and yes it is, but to set it up is a very time consuming task.  

Most of the time searching on Google or duckduckgo is a panacea for all technological problems or blocks.  However I found no resource is complete and takes long to figure out that, also most of them out-dated.

Anyway here is the checklist, I am not putting any links here as its easy to find out how to fulfil each checkpoint.  My try is to make it version agnostic.


Installations required


Java
Maven
Android sdk
Eclipse

System Configuration (Win64)


1. Set up home variables for Java, Maven, Android
2. Set up path for Java, android_home/tools, M2_HOME/bin

Eclipse JVM settings


1. JRE settings - JAVA_HOME/jre
2. Maven settings - i preferred to have external maven
3. Android setup home
4. Eclipse plugins
- m2e
- android
- m2e-eclipse-android-plugin


Maven Configurations


1. Download maven archetype catalog xml as central-archetype-catalog.xml on to .m2 directory [ in same directory where your settings.xml reside]
http://repo1.maven.org/maven2/archetype-catalog.xml
2. Install for android SDK Manager, install all extras for step3 mvn install to work
3. download and mvn install Maven Android SDK Deployer
4. install appropriate to your sdk version with -P option


Create a Maven Project from Archetypes

1. Create a folder for project using windows explorer
2. Eclipse Menu
file >> new Maven Project >>
3. uncheck default location and browse the one created in step 1
4. Create Catalog -> local Archetype catalog -> select catalog xml created in Maven conf step1.
5. back in New Maven Project window, select newly created catalog, type filter android
6. select android-quickstart, and next
7. type groupid(your pkg name) and artifactid (your project name) and finish
8. Archetype will create sample project, with sample pom.xml, which needs a change
If all is well, eclipse will show 1 compile-time error for R.java, that's fine. Keep going
Before continuing complete pom and settings file changes and then run mvn clean install, this should build successfully.


Further settings.xml and pom.xml settings


POM Changes
1. add dependency and adjust version number appropriately

<dependencies>

<dependency>

<groupId>android</groupId>

<artifactId>android</artifactId>

 <version>4.0.3_r3</version>

  <scope>provided</scope>

</dependency>

</dependencies>



2. also adjust SDK version number appropriately in plugin

<configuration>

<androidManifestFile>${project.basedir}/AndroidManifest.xml</androidManifestFile>

<assetsDirectory>${project.basedir}/assets</assetsDirectory>

<resourceDirectory>${project.basedir}/res</resourceDirectory>

<nativeLibrariesDirectory>${project.basedir}/src/main/native</nativeLibrariesDirectory>

<sdk>

<platform>15</platform> 



3. Last add these 3 sections to settings.xml

<pluginGroup>

com.jayway.maven.plugins.android.generation2</pluginGroup>

</pluginGroups>



<profile>

<id>android</id>

<properties>

<android.sdk.path>C:\Androiddev\android-sdk</android.sdk.path>

</properties>

</profile>




<activeProfiles> 

<activeProfile>android</activeProfile>

</activeProfiles>



If you think something is missing or required, pl drop a line.

JS

No comments:

Post a Comment