打开该网页,点击 GettingStarted 跳转到http://code.google.com/p/maven-android-plugin/wiki/GettingStarted 该页面
想编译Android项目还差最后一部 ,用git把 Maven AndroidSDK Deployer 项目载到本地
- 在此之前的环境都搭建完毕的前提下,进入该项目的跟目录
- 执行 mvn clean install 。 就会自动构建Android-maven的编译环境
mvn install -P 4.0 会把 相关的sdk 上传到 maven仓库中 折腾了 老子一天 由于家里网不行 maven依赖的jar都下载不下来 到公司都OK - 中途会下载一些东西,检查你的sdk等等,稍作等候即可
- [INFO] ------------------------------------------------------------------------
- [INFO] Reactor Summary:
- [INFO]
- [INFO] Maven Android SDK Deployer ........................ SUCCESS [0.232s]
- [INFO] Android Platforms ................................. SUCCESS [0.007s]
- [INFO] Android Platform 1.5 API 3 ........................ SUCCESS [0.065s]
- [INFO] Android Platform 1.6 API 4 ........................ SUCCESS [0.013s]
- [INFO] Android Platform 2.1 API 7 ........................ SUCCESS [0.012s]
- [INFO] Android Platform 2.2 API 8 ........................ SUCCESS [0.013s]
- [INFO] Android Platform 2.3.3 API 10 ..................... SUCCESS [0.013s]
- [INFO] Android Platform 3.0 API 11 ....................... SUCCESS [0.028s]
- [INFO] Android Platform 3.1 API 12 ....................... SUCCESS [0.013s]
- [INFO] Android Platform 3.2 API 13 ....................... SUCCESS [0.013s]
- [INFO] Android Platform 4.0 API 14 ....................... SUCCESS [0.012s]
- [INFO] Android Platform 4.0.3 API 15 ..................... SUCCESS [0.013s]
- [INFO] Android Platform 4.1 API 16 ....................... SUCCESS [0.013s]
- [INFO] Android Platform 4.2 API 17 ....................... SUCCESS [0.012s]
- [INFO] Android Add-Ons ................................... SUCCESS [0.006s]
- [INFO] Android Add-On Google Platform 1.5 API 3 (Maps) ... SUCCESS [0.018s]
- [INFO] Android Add-On Google Platform 1.6 API 4 (Maps) ... SUCCESS [0.013s]
- [INFO] Android Add-On Google Platform 2.1 API 7 (Maps) ... SUCCESS [0.013s]
- [INFO] Android Add-On Google Platform 2.2 API 8 (Maps) ... SUCCESS [0.014s]
- [INFO] Android Add-On Google Platform 2.3.3 API 10 (Maps and USB) SUCCESS [0.017s]
- [INFO] Android Add-On Google Platform 3.0 API 11 (Maps) .. SUCCESS [0.013s]
- [INFO] Android Add-On Google Platform 3.1 API 12 (Maps and USB) SUCCESS [0.017s]
- [INFO] Android Add-On Google Platform 3.2 API 13 (Maps and USB) SUCCESS [0.016s]
- [INFO] Android Add-On Google Platform 4.0 API 14 (Maps and USB) SUCCESS [0.017s]
- [INFO] Android Add-On Google Platform 4.0.3 API 15 (Maps and USB) SUCCESS [0.018s]
- [INFO] Android Add-On Google Platform 4.1 API 16 (Maps and USB) SUCCESS [0.019s]
- [INFO] Android Add-On Google Platform 4.2 API 17 (Maps and USB) SUCCESS [0.018s]
- [INFO] Android Extras .................................... SUCCESS [0.009s]
- [INFO] Android Compatibility Extra V4 .................... SUCCESS [0.013s]
- [INFO] Android Compatibility Extra V7 Gridlayout Library . SUCCESS [1.999s]
- [INFO] Android Compatibility Extra V13 ................... SUCCESS [0.009s]
- [INFO] Android Google Analytics Extra .................... SUCCESS [0.009s]
- [INFO] Android Google AdMob Ads Extra .................... SUCCESS [0.009s]
- [INFO] Android Google Cloud Messaging Library Extra Parent SUCCESS [0.006s]
- [INFO] Android Google Cloud Messaging Client Library Extra SUCCESS [0.010s]
- [INFO] Android Google Cloud Messaging Server Library Extra SUCCESS [0.010s]
- [INFO] Android Google Play Services Extra ................ SUCCESS [0.460s]
- [INFO] Android Google Play Licensing Extra ............... SUCCESS [0.297s]
- [INFO] Android Extras - Apk Expansion .................... SUCCESS [0.006s]
- [INFO] Android Google Play APK Expansion Extra - ZIP ..... SUCCESS [0.240s]
- [INFO] Android Google Play APK Expansion Extra - Downloader SUCCESS [0.314s]
- [INFO] Android Tools ..................................... SUCCESS [0.004s]
- [INFO] Android Annotations ............................... SUCCESS [0.007s]
- [INFO] ------------------------------------------------------------------------
- [INFO] BUILD SUCCESS
- [INFO] ------------------------------------------------------------------------
- [INFO] Total time: 5.277s
- [INFO] Finished at: Mon Dec 31 16:42:23 CST 2012
- [INFO] Final Memory: 24M/298M
- [INFO] ------------------------------------------------------------------------
- 出现以上,就代表 android-maven的初步环境构建完毕
- cd ~/.m2/ 到该目录下打开repository的文件夹即可查看到已经配置好相关的Android环境了
- 测试android-maven
- 下载可供给打包测试的例子代码 Download samples from the stable branch
- 解压该项目,进入 jayway-maven-android-plugin-samples-b17572a 文件夹
- drwxrwxr-x 4 wuyexiong wuyexiong 4096 12月 31 15:49 apidemos-android-10/
- -rw-rw-r-- 1 wuyexiong wuyexiong 136 12月 19 10:25 .gitignore
- drwxrwxr-x 4 wuyexiong wuyexiong 4096 12月 19 10:25 helloflashlight/
- drwxrwxr-x 6 wuyexiong wuyexiong 4096 12月 19 10:25 libraryprojects/
- -rw-rw-r-- 1 wuyexiong wuyexiong 10173 12月 19 10:25 LICENSE.txt
- drwxrwxr-x 5 wuyexiong wuyexiong 4096 12月 19 10:25 morseflash/
- drwxrwxr-x 13 wuyexiong wuyexiong 4096 12月 19 10:25 native/
- -rw-rw-r-- 1 wuyexiong wuyexiong 7548 12月 19 10:25 pom.xml
- -rw-rw-r-- 1 wuyexiong wuyexiong 942 12月 19 10:25 README.txt
- drwxrwxr-x 4 wuyexiong wuyexiong 4096 12月 19 10:25 scala/
- drwxrwxr-x 5 wuyexiong wuyexiong 4096 12月 31 15:34 support4demos/
- 可以看到都是一些例子的代码。
- 这时候可以进入具体的一个项目,比如进入support4demos
- -rw-rw-r-- 1 wuyexiong wuyexiong 10630 12月 19 10:25 AndroidManifest.xml
- -rw-rw-r-- 1 wuyexiong wuyexiong 1909 12月 19 10:25 pom.xml
- -rw-rw-r-- 1 wuyexiong wuyexiong 377 12月 19 10:25 README.txt
- drwxrwxr-x 10 wuyexiong wuyexiong 4096 12月 19 10:25 res/
- drwxrwxr-x 3 wuyexiong wuyexiong 4096 12月 19 10:25 src/
- 这是完整项目的文件了
- 打开模拟器,或者链接上手机,执行 mvn clean install 即可编该程序了
- 也可以只是执行 mvn package 来进行打包, 即可在项目下生成一个target的目录,目录底下都是一些目标文件
- 这两种默认都是以debug签名的,更多待研究了。。。
- 最后执行 mvn android:deploy 即可安装到模拟器或者手机
- 编译并安装是执行 mvn clean install android:deploy
- [INFO]
- [INFO] ------------------------------------------------------------------------
- [INFO] Building Android Support V4 Demos 1.0.0-SNAPSHOT
- [INFO] ------------------------------------------------------------------------
- [INFO]
- [INFO] --- android-maven-plugin:3.5.0:deploy (default-cli) @ support4demos ---
- [INFO] Waiting for initial device list from the Android Debug Bridge
- [INFO] Found 1 devices connected with the Android Debug Bridge
- [INFO] android.device parameter not set, using all attached devices
- [INFO] Successfully installed /home/wuyexiong/Android/tool/maven/jayway-maven-android-plugin-samples-b17572a/support4demos/target/support4demos.apk to MX3ACA1ALGVA8Q1125_Meizu_M031
- [INFO] ------------------------------------------------------------------------
- [INFO] BUILD SUCCESS
- [INFO] ------------------------------------------------------------------------
- [INFO] Total time: 8.965s
- [INFO] Finished at: Mon Dec 31 16:55:09 CST 2012
- [INFO] Final Memory: 17M/146M
- [INFO] ------------------------------------------------------------------------
本章到此了,我也是刚研究这个,因为发现github上面很多开源项目都是带有pom.xml这个文件的,所以下了解一下,最好能深入一下。
循序渐进吧。等待研究更深入的东西,把笔记都记到这上面