Ubuntu 14.04 Android 使用Maven二 建立自己的Mavenproject

來源:互聯網
上載者:User

標籤: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

部署成功後,會看到類比裝置上出現程式表徵圖。

點擊執行,成功。




聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.