2013-05-17 45 views
42

我試圖遵循本教程:的Android的Maven找不到工具「AAPT」

http://www.gdgankara.org/2012/11/01/step-by-step-android-development-with-maven/

但設置環境,並創建一個項目,在「運行方式\ Maven的安裝」後,一步我得到這個:

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". 
SLF4J: Defaulting to no-operation (NOP) logger implementation 
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. 
[INFO] Scanning for projects... 
[INFO]                   
[INFO] ------------------------------------------------------------------------ 
[INFO] Building tutorial 0.0.1-SNAPSHOT 
[INFO] ------------------------------------------------------------------------ 
[INFO] 
[INFO] --- android-maven-plugin:3.1.1:generate-sources (default-generate-sources) @ tutorial --- 
[INFO] ANDROID-904-002: Found aidl files: Count = 0 
[INFO] ANDROID-904-002: Found aidl files: Count = 0 
[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD FAILURE 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 1.889s 
[INFO] Finished at: Sat May 18 00:32:12 CEST 2013 
[INFO] Final Memory: 8M/111M 
[INFO] ------------------------------------------------------------------------ 
[ERROR] Failed to execute goal com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.1.1:generate-sources (default-generate-sources) on project tutorial: Execution default-generate-sources of goal com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.1.1:generate-sources failed: 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. -> [Help 1] 
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. 
[ERROR] Re-run Maven using the -X switch to enable full debug logging. 
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles: 
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException 

我試了很多次,但沒有運氣。 我在Windows7 64位上安裝了Eclipse Juno,安裝了APK Tool並且安裝了Maven 3.0.5。

似乎對行家人員衆所周知的問題:

https://code.google.com/p/maven-android-plugin/issues/detail?id=104

但它應該從年齡來解決......

我的環境用戶變量:

M2_HOME=C:\Program Files\Java\apache-maven-3.0.5 

ANDROID_HOME=C:\adt-bundle-windows-x86_64-20130514\sdk 

我環境系統變量:

Path=......;%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools;%ANDROID_HOME%\build-tools;%ANDROID_HOME%\platforms;%M2_HOME%\bin;%ANDROID_HOME%\build-tools\android-4.2.2 

有誰知道如何鍛鍊這個陷阱?

謝謝!

回答

95

我使用最新的ADT時從谷歌和試圖編譯引導android平臺也遇到了同樣的問題。

最新的R17構建分離出aapt構建工具文件夾中。因此它是maven-android-plugin不能支持它。

見問題討論here

嘗試和工作:

cd $ANDROID_HOME/platform-tools 
ln -s ../build-tools/17.0.0/aapt aapt 
ln -s ../build-tools/17.0.0/lib lib 
ln -s ../build-tools/17.0.0/aidl aidl 

請記住,這是在最新的版本(> 3.5.3):

cd $ANDROID_HOME/platform-tools 
ln -s ../build-tools/android-4.2.2/aapt aapt 
ln -s ../build-tools/android-4.2.2/lib lib 
ln -s ../build-tools/android-4.2.2/aidl aidl 

某些安裝可以使用API​​版本結構正如其他答案指出的那樣,Android Maven插件。

+3

哦,我明白了。很清楚。我認爲我是安全的,將「%ANDROID_HOME%\ build-tools \ android-4.2.2」語句添加到環境路徑中......反正我求求你原諒,但是,有沒有辦法在windows中添加這些命令? 我可以鍛鍊這個附加的lib,aapt和aidl環境路徑變量嗎? –

+0

我也看到有新的SDK結構的修復: https://github.com/jayway/maven-android-plugin/pull/205 我不明白的地方我應該把那新類... –

+0

我懷疑windows用戶喜歡我,即使與mklink,不能追加到ANDROID_HOME的軟鏈接,所以註定... –

14

如果您使用的是Windows,符號鏈接可以使用mklink命令來完成。

D:\>cd "Program Files (x86)\Android\android-sdk" 

D:\Program Files (x86)\Android\android-sdk>cd platform-tools 

D:\Program Files (x86)\Android\android-sdk\platform-tools>mklink aapt.exe ..\build-tools\17.0.0\aapt.exe 
symbolic link created for aapt.exe <<===>> ..\build-tools\17.0.0\aapt.exe 

D:\Program Files (x86)\Android\android-sdk\platform-tools>mklink aidl.exe ..\build-tools\17.0.0\aidl.exe 
symbolic link created for aidl.exe <<===>> ..\build-tools\17.0.0\aidl.exe 

D:\Program Files (x86)\Android\android-sdk\platform-tools>mklink /d lib ..\build-tools\17.0.0\lib 
symbolic link created for lib <<===>> ..\build-tools\17.0.0\lib 
+0

這解決了我的問題(現在)。現在我們只需要等待android maven插件來支持新的結構。 – JesperB

21

更新:

這一直以來Android Maven Plugin v3.6.0解決。現在,如果您使用IntelliJ v12.x,則只需要這些符號鏈接。 IntelliJ v13 EAP +應該可以開箱即用。

原來的答覆:

該問題已解決,並會與Android Maven插件v3.5.4發佈。見GitHub的拉請求:

Upgraded AndroidSdk to use path and platform utilities from sdklib

您可以嘗試驗證快照構建其通過添加以下到您的pom.xml包含修訂:

<plugin> 
    <groupId>com.jayway.maven.plugins.android.generation2</groupId> 
    <artifactId>android-maven-plugin</artifactId> 
    <version>3.5.4-SNAPSHOT</version> 
    ... 
</plugin> 
... 
<pluginRepositories> 
    <pluginRepository> 
    <id>oss.sonatype.org-jayway-snapshots</id> 
    <name>Jayway OpenSource SNAPSHOTs on Sonatype.org</name> 
    <url>http://oss.sonatype.org/content/repositories/jayway-snapshots/</url> 
    <snapshots> 
     <enabled>true</enabled> 
    </snapshots> 
    </pluginRepository> 
</pluginRepositories> 

請開發組提供反饋:

New snapshot for 3.5.4 available

+0

將版本更改爲3.6.0並且可以正常工作。謝謝。 – tmin

+0

版本3.5.3不起作用。我遇到了運行3.5.3的相同問題,我還沒有嘗試過3.5.4或3.6.0。 –

0

我卡住同樣的問題。最後,我設法在兩個小時後解決問題。爲簡單起見並解決問題在5分鐘內我下面列出

步驟

步驟1 - 在Eclipse中使用測試版的鏈接 http://rgladwell.github.io/m2e-android/updates/master/

更新的Android Maven插件到0.4.3.2013步驟2

 <plugin> 
     <groupId>com.jayway.maven.plugins.android.generation2</groupId> 
     <artifactId>android-maven-plugin</artifactId> 
     <version>3.6.1</version> 
     <configuration> 
      <sdk> 
       <platform>17</platform> 
      </sdk> 
     </configuration> 
    </plugin> 

這將解決以下問題

"No Android Platform Version/API Level has been configured"

Could not find tool 'aapt'

希望它可以幫助

0

我也曾經有過類似的問題。

通過以下步驟解決:

1)升級到行家3.1.1 2)使用Android-行家-插件3.6.1 PR更大[I使用3.8.0] 3)使用行家-dependency-插件2.8

如果你想建立針對最新的Android SDK [例如:4.3],請按照下面的附加步驟 - 4)安裝使用的android.jar命令的本地副本MVN安裝:installFile .. 5)設置18

希望這會有所幫助。