---
title: "maven部署android项目(1)"
author: "v5qqbrowser"
date: "2013-01-07T16:21:00Z"
tags: []
slug: "maven-android-1"
draft: false
lastmod: "2013-02-01T14:13:38Z"
id: 1782670
url: "https://v5qqbrowser.iteye.com/blog/1782670"
---

花了半天的时间终于搞定了maven下部署android工程。

[http://code.google.com/p/maven-android-plugin/wiki/GettingStarted](http://code.google.com/p/maven-android-plugin/wiki/GettingStarted)这是官方文档，介绍的很详细，但是有很多细节不得不再次描述一下。

准备工具：

1.Eclipse juno 4.2.1 下载地址： [http://www.eclipse.org/downloads/packages/eclipse-classic-421/junosr1](http://www.eclipse.org/downloads/packages/eclipse-classic-421/junosr1)

2.ADT-21.0.1.zip(android开发插件)下载地址： [http://developer.android.com/sdk/index.html](http://developer.android.com/sdk/index.html)

3.apache-maven-3.0.4-bin.zip 下载地址：[http://maven.apache.org/download.cgi](http://maven.apache.org/download.cgi)

4.android-m2e(android环境下的maven-eclipse插件) updatesite：[http://rgladwell.github.com/m2e-android/updates/](http://rgladwell.github.com/m2e-android/updates/)(在eclipse下安装，具体不描述)

需要重点说明的是第4步，因为我用的eclipse是4.2版本的，版本比较新，所以在安装android-m2e的时候会发现有很多jar包找不到导致该插件无法安装，经过调查研究发现，有几个jar包是必须通过手工添加才可以的。

首先在eclipse的install列表中选择：

其次首先选择添加这几个插件：

别问我为什么添加，我只知道添加之后你可以正常的安装m2e插件了，至于为什么只好去问eclipse了，呵呵。

到此为止环境就添加完了，如果有朋友到这步环境仍然有问题，请发站内信与我联系，我会指导你解决问题，谢谢。

====================================maven下搭建android项目=========================================

第一步，配置一下maven的settings.xml文件，这个文件的位置在，apache-maven-3.0.4-bin\\apache-maven-3.0.4\\conf\\settings.xml，修改内容为：

```
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> 
  <profiles> 
    <profile> 
      <id>android</id> 
        <properties> 
          <android.sdk.path> 
			E:\dev_tool\android-sdks（android-SDK home路径）
          </android.sdk.path> 
        </properties> 
	  </profile> 
    </profiles> 
	<activeProfiles> <!--make the profile active all the time --> 
      <activeProfile>android</activeProfile> 
	</activeProfiles> 
</settings>
```

第二步，在eclipse里面配置maven插件，windows-Preference--Maven--Installations

===============================================================================================================

ok!Maven配置完成了

第三步，在现有的项目中添加maven配置，右键选中项目---&gt;Configure----&gt;Convert to Maven Project

============================未完，待续=========================================