Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert my Android project to a maven project

I have an Android project developed with Eclipse & pushed to github.

Now I want to convert my Android project to a maven project, how to do that?

like image 969
Mellon Avatar asked Sep 16 '13 11:09

Mellon


1 Answers

Try to follow the Getting Started Guide of the maven-android-plugin. In order to convert your already existing project you basically have to:

1) Create a pom.xml. For this you can use the maven archetype as described here:

mvn archetype:generate   
   -DarchetypeArtifactId=android-quickstart   
   -DarchetypeGroupId=de.akquinet.android.archetypes   
   -DarchetypeVersion=1.0   
   -DgroupId=your.company   
   -DartifactId=my-android-application

This will create the pom.xml and the directory structure mandated by maven.

2) Move your code into the respective folders under src/main/java.

3) Make sure you have the android sdk installed and in your path, the correct android platform version installed and referenced in your pom. Also make sure you have set all environment variables as required on the maven-android-plugin page

4) Issue mvn clean install on the command line and check if the build works

5) Plug in your Android device and issue mvn android:deploy. This should install the App on your mobile phone (you can verify the device's precence with mvn android:devices. If you want to execute the app in the emulator, start it first with mvn android:emulator-start and then deploy it.

6) Remove old files and folders that are no longer necessary.

7) In Eclipse, make sure you have maven support enabled and re-import your project. When Eclipse builds the project, it may complain about missing maven plugin support. Open Eclipse Marketplace and install the Android Configurator for m2e, then it should be ok.

like image 92
Kai Sternad Avatar answered Oct 02 '22 15:10

Kai Sternad