---
title: "Maven开发Android指南 4 与Eclipse整合（m2e-android ）"
author: "reymont"
date: "2012-12-21T11:10:23Z"
tags: []
categories: ["移动开发"]
slug: "maven-android-4-eclipse-m2e-android"
draft: false
lastmod: "2012-12-21T11:10:23Z"
id: 1751587
url: "https://reymont.iteye.com/blog/1751587"
---

Android官方开发团队致力于为Ecilpse插件提供可靠的支持，而android-maven-plugin致力于将Maven，Android和Eclipse串联在一起。

 

m2e-android是一个 Maven Integration for Eclipse (m2e) plug-in，为Android Developer Tools (ADT)和 Maven Android Plugin添加Maven支持，为ADT提供Maven依赖管理的特性。

 

安装m2e-android需要[Eclipse Indigo or Juno](http://www.eclipse.org/downloads/) （低版本的Eclispe未提供Eclipse Marketplace）

 

*Help -&gt; Eclipse Marketplace...* 输入 "android m2e".点击Install（包含了Android Development Toolkit 和Maven for Eclipse m2e plug-in）。

**创建项目：**

如果是已经使用《[Maven开发Android指南 3 使用Android Maven Archetypes 创建新项目](http://reymont.iteye.com/blog/1751133)》的方法创建项目，直接使用Eclipse Import：File-&gt;Maven-&gt;Existing Maven Projects

 

也可以使用m2e-android利用Maven Android archetypes创建新的项目：

 

![](http://dl.iteye.com/upload/attachment/0078/2453/b3a4be80-b049-3adc-b29e-b2350e8d2ef6.png)  
直接Next

![](http://dl.iteye.com/upload/attachment/0078/2469/b788066f-2d3a-3293-90c3-ec5601db9d46.png)  
选择All Catalogs，Filter输入de.akquinet.android.archetypes

![](http://dl.iteye.com/upload/attachment/0078/2455/dae0e593-9f4b-3d02-af4a-1f6d3877c84b.png)  
在Group Id、Artifact Id和Package输入名称

![](http://dl.iteye.com/upload/attachment/0078/2457/fc1ce0c1-7fa5-3cf6-8e1e-b1e5ca022472.png)  
创建完后，可能有错。

![](http://dl.iteye.com/upload/attachment/0078/2459/dd4f0c46-1305-3f16-924b-dc2ef02455e3.png)  
右键Properties查看，提示为缺少src/test/java文件夹。

![](http://dl.iteye.com/upload/attachment/0078/2461/05829581-e398-3b2c-bcd2-789664e1e33e.png)  
在工程目录下新建对应文件夹。

![](http://dl.iteye.com/upload/attachment/0078/2463/b06c5da7-1893-3800-9d97-91fb26a0f1ba.png)  
参照《[Maven开发Android指南 3 使用Android Maven Archetypes 创建新项目](http://reymont.iteye.com/blog/1751133)》章节创建AVD后，可以使用Eclipse直接运行Android了。

![](http://dl.iteye.com/upload/attachment/0078/2467/7d26ff1c-bdbc-3d0e-94e2-8e6e95e00e5b.png)  
当然也可以采用命令行：

mvn android:emulator-start  
mvn clean package android:deploy  
android:run

**参考：**

[http://rgladwell.github.com/m2e-android/](http://rgladwell.github.com/m2e-android/)

[http://code.google.com/p/maven-android-plugin/wiki/EclipseIntegration](http://code.google.com/p/maven-android-plugin/wiki/EclipseIntegration)