使用Maven編譯Android下i-jetty的一些問題

來源:互聯網
上載者:User

假設已安裝eclipse、adt及android SDK,除了這些還必須做以下配置:

1、m2eclipse
eclipse外掛程式地址:http://m2eclipse.sonatype.org/sites/m2e
如不知,請自行搜尋怎樣線上安裝Eclipse外掛程式

2、maven
其實,m2eclipse已內建maven。若想使用外部的maven,需使用下面的地址來下載http://maven.apache.org/
下載並解壓完成後,需在Eclipse->window->preferences->Maven->Installations->Add中添加並使用Maven安裝路徑。

3、配置環境變數
Window: %MAVEN_HOME% %ANDROID_HOME%
Linux: $MAVEN_HOME $ANDROID_HOME

若不能正常運行,請嘗試在PATH變數中添加%MAVEN_HOME%\bin和%ANDROID_HOME%\tools

4、i-jetty下載及匯入Eclipse
源碼地址:http://code.google.com/p/i-jetty/downloads/list

使用Import->Maven->Existing Maven Projects來匯入i-jetty的Maven項目

5、Eclipse下編譯Maven項目ijetty-parent
Run as -> maven clean -> maven install 即可。

6、碰到的問題

1
2
Cannot find required method
java.lang.NoSuchMethodException: com.android.sdklib.build.ApkBuilder.addNativeLibraries(java.io.File,
java.lang.String)

這個主要是android sdk版本比較新,而maven-android-plugin版本較舊引起。
解決辦法:

1
2
3
<groupid>com.jayway.maven.plugins.android.generation2</groupid>
<artifactid>maven-android-plugin</artifactid>
<version>2.9.0-beta-5</version>

在pom.xml中找到上面的位置,把maven-android-plugin改為android-maven-plugin,2.9.0-beta-5改為3.0.0即可。

在執行dx.jar時,報以下錯誤:

1 java.lang.OutOfMemoryError: Java heap space

很明顯,android sdk中的dex轉換需要更多記憶體。
解決辦法:

1
2
3
4
5
6
<dex>
<jvmarguments>
<jvmargument>-Xms256m</jvmargument>
<jvmargument>-Xmx512m</jvmargument>
</jvmarguments>
</dex>

在pom.xml中配置maven-android-plugin的/下添加以上代碼。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.