標籤:
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將不報錯
來自為知筆記(Wiz)
Android Maven 工程