Prerequisites:
1. Install Maven (Download: apache-maven-3.0.5-bin.zip )
- Edit ‘Environment Variables’ -> Add new user variable “M2_HOME” = C:\Program Files\apache-maven-3.0.5
- Update system variable ‘Path’ -> Add %M2_HOME%\bin; at the end of variable value
2. Install Android SDK
- Edit ‘Environment Variables’ -> Add new user variable “ANDROID_HOME”
- Update system variable ‘Path’ –> Add %ANDROID_HOME%\tools; and %ANDROID_HOME%\platform-tools;
Create Android Project:
1. Create a new folder ‘MyProjects’. Select folder -> Press Shift +Right Click ->Select ‘Open command window here’
2. Enter the following command:
mvn archetype:generate -DarchetypeArtifactId=android-quickstart -DarchetypeGroupId=de.akquinet.android.archetypes -DarchetypeVersion=1.1.0 -DgroupId=com.testapp -DartifactId=my-android-application -Dversion=1.0
- This creates an android-quickstart project with following config properties;
- New project named ‘my-android-application’ will be generated inside ‘MyProject’ folder. Generated project contains AndroidManifest.xml and pom.xml files.
- Note: Open the pom.xml file -> change the ‘android-plugin-version’ value to 3.6.0 and Save.
Import the Project to Eclipse IDE
The new project created from Maven archetypes, cannot directly import to Eclispe. For that we need to run a new command to convert the project to an eclipse project.
1. Open command prompt from project folder. Enter the following command
mvn eclipse:clean eclipse:eclipse
This command generates .classpath and .project files.
2. Open Eclipse workspace –> Windows -> Preferences
- Navigate to Maven -> Installations
- Disable Embedded Maven Installation.
- Add ‘External Maven Installation’ -> C:\Program Files\apache-maven-3.0.5. Apply Ok.
- Make sure you have set Andorid SDK preferences.
3. Goto Import –> General -> Existing Project into Workspace -> Navigate and select ‘my-android-applicaton’ project -> Finish
Initially the project structure looks like this:
4. Goto Project Properties -> JavaBuildPath -> Remove references to M2 Repository.
Note: You will get errors at Project src.
5. Right Click on Project -> Config -> Convert to Maven Project
This will refresh Maven Dependecies and Fix the project errors.
6. You can add new dependencies at pom.xml file
Ex: Ad