Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add Maven to an existing IntelliJ Android project

I've been doing some research on adding Maven to an existing Android project and I'm struggling to see how this works. I've used Maven once at work on a web based project with Netbeans, but for this project I'm looking to use IntelliJ. I can create a new "Maven Module", but I already have an Android project so I'm not entirely sure that's the route I should be taking.

I found this post which does provide some detail, but not a step-by-step windows integration guide (at least that I'm seeing).

Is it possible for me to use Maven within an Android project?

Edit: I'm looking to do this within a Windows environment

like image 879
Webnet Avatar asked Dec 27 '12 04:12

Webnet


1 Answers

To answer your question in the last sentence: Yes, you can use Maven to build an Android project.

You should use the maven-android-plugin in your Maven project. The best place to get started is https://code.google.com/p/maven-android-plugin/wiki/GettingStarted. Need to read up a bit, but definitely worth the effort.

If I have existing IDE specific Android project that you would like to switch to Maven, instead of trying to "add Maven support to an existing IntelliJ project", I would:

  1. Create a new Maven based project using an appropriate archetype https://github.com/akquinet/android-archetypes

  2. Copy existing source/resources to the Maven project directories.

If done correctly, you can open this (Android) Maven project (pom.xml) in IntelliJ and use it like an Android project (including GUI editor). IntelliJ automatically generates an IntelliJ project from Maven's pom.xml and detects the Android facet.

This way, your project also stays IDE agnostic - you can do everything (build/test/deploy) from command line as well - how Maven projects should be IMHO. :D

like image 94
kctang Avatar answered Oct 26 '22 23:10

kctang