How to convert my Android project to maven project

I have an Android project developed using Eclipse and ported to github.

Now I want to convert an Android project to a maven project, how to do it?

+6
source share
1 answer

Try the maven-android-plugin module getting started guide . To convert an existing project, you basically need to:

1) Create pom.xml . You can use the maven archetype for this, 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 pom.xml and the directory structure specified by maven.

2) Move your code to the appropriate folders under src/main/java .

3) Make sure you have the sdk Android device installed and the correct version of the Android platform is installed in your path and is listed in your pom. Also make sure you set all environment variables as needed on the maven-android-plugin page

4) The mvn clean install problem is on the command line and check if the build is working

5) Connect the Android device and enter mvn android:deploy . This should install the application on your mobile phone (you can check the accuracy of the device using mvn android:devices . If you want to run the application in the emulator, first run it using mvn android:emulator-start , and then expand it.

6) Delete old files and folders that are no longer needed.

7) In Eclipse, make sure you support maven and reimport your project. When Eclipse creates a project, it may complain about the lack of support for the maven plugin. Open the Eclipse Marketplace and install Android Configurator for m2e, then it will be ok.

+6
source

Source: https://habr.com/ru/post/953908/


All Articles