標籤:android style class blog code java
依據https://code.google.com/p/maven-android-plugin/wiki/GettingStarted 介紹,有兩種方法能夠建立Mavenproject。
第一種方法是用archetype, 可是我使用了之後,發現archetype產生的項目編譯時間有一個依賴找不到,無論了,先換其它方法。
另外一種方法就是使用android命令列建立項目,然後複製範例代碼project的pom檔案並改動,
Ubuntu 14.04 設定Android開發環境 描寫敘述了怎樣用命令列建立項目
Ubuntu 14.04 Android 使用Maven一 使用範例project介紹了範例projecthelloflashlight
先建立一個項目mvn_example1
android create project --target android-10 --name mvn_example1 --path mvn_example1 --activity MainActivity --package org.csfreebirdCreated project directory: mvn_example1Created directory /home/dean/work/gitlab_cloud/android/example/mvn_example1/src/org/csfreebirdAdded file mvn_example1/src/org/csfreebird/MainActivity.javaCreated directory /home/dean/work/gitlab_cloud/android/example/mvn_example1/resCreated directory /home/dean/work/gitlab_cloud/android/example/mvn_example1/binCreated directory /home/dean/work/gitlab_cloud/android/example/mvn_example1/libsCreated directory /home/dean/work/gitlab_cloud/android/example/mvn_example1/res/valuesAdded file mvn_example1/res/values/strings.xmlCreated directory /home/dean/work/gitlab_cloud/android/example/mvn_example1/res/layoutAdded file mvn_example1/res/layout/main.xmlAdded file mvn_example1/AndroidManifest.xmlAdded file mvn_example1/build.xmlAdded file mvn_example1/proguard-project.txt
如今複製heelloflashlight的pom.xml檔案到該專案檔夾下, 然後改動當中的一些配置:
<groupId>org.freebird</groupId> <artifactId>example1</artifactId> <version>1.0.0</version> <packaging>apk</packaging> <name>mvn_example1</name>
設定platform版本號碼為10,這裡使用的是API Level,也能夠使用platform level: 2.3.3, 詳細能夠通過命令android list targets, 只是這裡眼下還僅僅能設定16, 設定10部署會失敗,臨時不明確原因。
<plugins> <plugin> <groupId>com.jayway.maven.plugins.android.generation2</groupId> <artifactId>android-maven-plugin</artifactId> <configuration> <sdk> <!-- platform as api level (api level 16 = platform 4.1)--> <platform>10</platform> </sdk> </configuration> </plugin> </plugins>
刪除掉ant相關的檔案:
mvn_example1$ rm -r bin build.xml build.properties libsrm: cannot remove ‘build.properties’: No such file or directory
啟動類比裝置後,執行以下的命令編譯和部署:
mvn clean installmvn android:deploy
部署成功後,會看到類比裝置上出現程式表徵圖。
點擊執行,成功。