2014-01-27 46 views
3

我嘗試了每個廣告方法,在嘗試使用android-maven-plugin構建Android應用程序時指定我的Android SDK的路徑,但沒有任何效果。無論我做什麼,當我運行無法獲取android-maven-plugin來識別SDK路徑

mvn clean install

我得到

... Could not find tool 'aapt'. Please provide a proper Android SDK directory path as configuration parameter <sdk><path>...</path></sdk> in the plugin <configuration/>. As an alternative, you may add the parameter to commandline: -Dandroid.sdk.path=... or set environment variable ANDROID_HOME.

我設置環境變量ANDROID_HOME指向SDK的根目錄下,並出口了。然後

<plugin> 
    <groupId>com.jayway.maven.plugins.android.generation2</groupId> 
    <artifactId>android-maven-plugin</artifactId> 
    ... 
    <configuration> 
     <sdk> 
      <path>${env.ANDROID_HOME}</path> 
      <platform>19</platform> 
     </sdk> 
     ... 
    </configuration> 
</plugin> 

不起作用。 (我有安裝在SDK API 19)

<plugin> 
    <groupId>com.jayway.maven.plugins.android.generation2</groupId> 
    <artifactId>android-maven-plugin</artifactId> 
    ... 
    <configuration> 
     <sdk> 
      <path>/absolute/path/to/sdk</path> 
      <platform>19</platform> 
     </sdk> 
     ... 
    </configuration> 
</plugin> 

不起作用

<properties> 
     <android.sdk.path>/absolute/path/to/sdk</android.sdk.path> 
</properties> 

不工作。並且

mvn clean install -Dandroid.sdk.path=/absolute/path/to/sdk 

不起作用。

我也嘗試將SDK中的工具,平臺工具和構建工具/ 19.1.1目錄附加到$ PATH,並且這也不起作用。我的路徑上提供了aapt工具,但maven插件拒絕看到它。我搜索了網頁,我看到的唯一建議就是做我所做的。

我錯過了什麼?我在OSX系統上這樣做。

+0

看起來像你的'ANDROID_HOME'?什麼android-maven-plugin版本? – MariuszS

+0

我認爲插件版本是問題。我使用3.1.1,從一個例子中我抓住了網絡。我試過3.8.2,最新的,我必須從maven2升級到maven3。現在會這樣做並報告回來,但這可能是問題所在。 – MidnightJava

+0

是的,當然,較舊的android-maven-plugins與新的android SDK不兼容。 – MariuszS

回答

1

舊版本的Android Maven Plugin可能無法與最新的SDK一起使用。例如,在版本3.6.0中添加了對SDK 22的支持。檢查changelog

3.6.0

該插件已經更新的SDK版本22.0的工作。 21.1在CI服務器上工作。它可能會或可能不適用於舊版本。

你並不需要配置ANDROID_HOME內pom.xml中,我的工作配置是這樣的:

<plugin> 
    <groupId>com.jayway.maven.plugins.android.generation2</groupId> 
    <artifactId>android-maven-plugin</artifactId> 
    <version>3.8.2</version> 

    <configuration> 
     <sdk> 
      <platform>19</platform> 
     </sdk> 
    </configuration> 
</plugin> 

配置ANDROID_HOME正確,對我來說這點到

.../adt-bundle-linux-x86_64-20131030/sdk/ 

製作確保它在調用maven之前被正確配置。例如,只需運行echo $ANDROID_HOME

+0

謝謝。我相信這正是我正在做的。在pom內部配置ANDROID_HOME只是我做了一些我認爲是正確的瘦無法正常工作的事情之一。我有ANDROID_HOME指向android sdk的rood目錄。我在調用maven之前用echo驗證它。 – MidnightJava

+0

@MidnightJava'android-maven-plugin'的版本是什麼?用-X執行maven構建併發布完整的錯誤。 – MariuszS

+0

在OP中給出的答案:android-maven-plugin和maven 3.1.1的版本3.8.2是正確的咒語。 – MidnightJava