1 maven-android-sdk-deployer插件安装
https://github.com/mosabua/maven-android-sdk-deployer 通过git下载工程
在环境变量中指定ANDROID_HOME、Path
ANDROID_HOME=F:\tools\adt-bundle-windows-x86_64-20130522\sdk
Path中添加:%ANDROID_HOME%\platform-tools;%ANDROID_HOME%\tools
在下载完Android SDK下所有内容后,执行 mvn clean install
执行结果:
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Maven Android SDK Deployer ........................ SUCCESS [0.240s]
[INFO] Android Platforms ................................. SUCCESS [0.065s]
[INFO] Android Platform 1.5 API 3 ........................ SUCCESS [0.182s]
[INFO] Android Platform 1.6 API 4 ........................ SUCCESS [0.058s]
[INFO] Android Platform 2.1 API 7 ........................ SUCCESS [0.058s]
[INFO] Android Platform 2.2 API 8 ........................ SUCCESS [0.053s]
[INFO] Android Platform 2.3.3 API 10 ..................... SUCCESS [0.058s]
[INFO] Android Platform 3.0 API 11 ....................... SUCCESS [0.054s]
[INFO] Android Platform 3.1 API 12 ....................... SUCCESS [0.061s]
[INFO] Android Platform 3.2 API 13 ....................... SUCCESS [0.056s]
[INFO] Android Platform 4.0 API 14 ....................... SUCCESS [0.061s]
[INFO] Android Platform 4.0.3 API 15 ..................... SUCCESS [0.061s]
[INFO] Android Platform 4.1 API 16 ....................... SUCCESS [0.182s]
[INFO] Android Platform 4.2 API 17 ....................... SUCCESS [2:02.331s]
[INFO] Android Add-Ons ................................... SUCCESS [0.016s]
[INFO] Android Add-On Google Platform 1.5 API 3 (Maps) ... SUCCESS [0.057s]
[INFO] Android Add-On Google Platform 1.6 API 4 (Maps) ... SUCCESS [0.039s]
[INFO] Android Add-On Google Platform 2.1 API 7 (Maps) ... SUCCESS [0.050s]
[INFO] Android Add-On Google Platform 2.2 API 8 (Maps) ... SUCCESS [0.088s]
[INFO] Android Add-On Google Platform 2.3.3 API 10 (Maps and USB) SUCCESS [0.061s]
[INFO] Android Add-On Google Platform 3.0 API 11 (Maps) .. SUCCESS [0.091s]
[INFO] Android Add-On Google Platform 3.1 API 12 (Maps and USB) SUCCESS [0.163s]
[INFO] Android Add-On Google Platform 3.2 API 13 (Maps and USB) SUCCESS [0.158s]
[INFO] Android Add-On Google Platform 4.0 API 14 (Maps and USB) SUCCESS [0.333s]
[INFO] Android Add-On Google Platform 4.0.3 API 15 (Maps and USB) SUCCESS [0.177s]
[INFO] Android Add-On Google Platform 4.1 API 16 (Maps and USB) SUCCESS [0.120s]
[INFO] Android Add-On Google Platform 4.2 API 17 (Maps and USB) SUCCESS [0.124s]
[INFO] Android Extras .................................... SUCCESS [0.028s]
[INFO] Android Compatibility Extra V4 .................... SUCCESS [0.515s]
[INFO] Android Compatibility Extra V7 Gridlayout Library . SUCCESS [4.079s]
[INFO] Android Compatibility Extra V13 ................... SUCCESS [0.113s]
[INFO] Android Google Analytics Extra .................... SUCCESS [0.032s]
[INFO] Android Google AdMob Ads Extra .................... SUCCESS [0.033s]
[INFO] Android Google Cloud Messaging Library Extra Parent SUCCESS [0.019s]
[INFO] Android Google Cloud Messaging Client Library Extra SUCCESS [0.036s]
[INFO] Android Google Cloud Messaging Server Library Extra SUCCESS [0.033s]
[INFO] Android Google Play Services Extra ................ SUCCESS [8.208s]
[INFO] Android Google Play Licensing Extra ............... SUCCESS [2.435s]
[INFO] Android Extras - Apk Expansion .................... SUCCESS [0.020s]
[INFO] Android Google Play APK Expansion Extra - ZIP ..... SUCCESS [5.850s]
[INFO] Android Google Play APK Expansion Extra - Downloader SUCCESS [14.588s]
[INFO] Android Tools ..................................... SUCCESS [0.018s]
[INFO] Android Annotations ............................... SUCCESS [0.337s]
[INFO] Repositories ...................................... SUCCESS [0.150s]
[INFO] Google M2Repository ............................... SUCCESS [0.571s]
[INFO] Android M2Repository .............................. SUCCESS [3.801s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2:47.691s
[INFO] Finished at: Fri Jul 12 12:21:29 CST 2013
[INFO] Final Memory: 25M/60M
[INFO] ------------------------------------------------------------------------
※错误分析1
[INFO] Android Google Play APK Expansion Extra - ZIP ..... FAILURE [1.002s]
...
[ERROR] 错误:读取 D:\.m2\repository\com\google\android\android\4.1.1.4\android-4.1.1.4.jar 时出错;error in opening zip file
[ERROR] 错误:读取 D:\.m2\repository\com\google\android\android\4.1.1.4\android-4.1.1.4.jar 时出错;cannot read zip file
...
【解决】到日志中提到的路径下打开android-4.1.1.4.jar出现
可见该错误应该是该jar包在下载过程中没有下载完全,根本无法打开,于是将4.1.1.4文件夹删除,重新执行mvn clean install -P 2.3.3执行成功
2 创建Android-quickstart-archtype(创建Maven的Android原型)
首先指向maven命令:
mvn archetype:generate -DarchetypeArtifactId=android-quickstart -DarchetypeGroupId=de.akquinet.android.archetypes -DarchetypeVersion=1.0.11 -DgroupId=com.neusoft -DartifactId=my-android-application
还可以追加参数-Dpackage=your.company.android 包名
-Demulator=my-avd 模拟器
下载相关的jar包
※其中archetypeArtifactId、archetypeGroupId、archetypeVersion都有可能改变,需要到http://search.maven.org/ 输入android-quickstart查询最新版本
工程创建成功
3 eclipse下创建maven-anroid-quickstart工程
1)新建Maven工程
2)使用默认选项继续下一步
3)选择模板
在Filter中输入android进行过滤,选择android-quickstart下一步
如果没有android-quickstart,需要点击【Add Archetype ...】添加模板
根据http://search.maven.org/ 搜索到的结果输入Group Id、Artifact Id、Version选择
4)指定工程选项
5)新建的工程会有红叉,
·右键工程 → Maven → Update Project Configuration
·Window → Performance → Maven → Discovery → 【Open Catalog】 下载m2e connector for android
【注】platform选择版本过低也会造成工程出现红叉,选择16将不报错