【问题标题】:Android Maven Could not find tool 'aapt'Android Maven 找不到工具“aapt”
【发布时间】:2013-05-17 23:14:43
【问题描述】:

我正在尝试学习本教程:

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

但是在设置环境并创建一个项目之后,在“运行为\maven install”步骤我得到了这个:

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 工具和 Maven 3.0.5。

对于 maven 员工来说,这似乎是一个众所周知的问题:

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

有人知道如何锻炼这个陷阱吗?

谢谢!

【问题讨论】:

    标签: android eclipse maven


    【解决方案1】:

    我在使用google最新的ADT并尝试编译bootstrap android平台时也遇到了同样的问题。

    最新的 r17 构建将 aapt 分离到 build-tools 文件夹。因此它是 maven-android-plugin 无法支持的。

    请参阅here 讨论的问题。

    尝试并工作:

    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 版本进行结构化:

    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) 的 Android Maven 插件中得到修复。

    【讨论】:

    • 哦,我明白了..很清楚。我认为我在环境路径中添加“%ANDROID_HOME%\build-tools\android-4.2.2”语句是安全的......无论如何我请你原谅,但有没有办法在 Windows 中添加这些命令?我可以将这个附加的 lib、aapt 和aidl 锻炼到环境路径变量吗?
    • 我还看到新的 SDK 结构有一个修复:github.com/jayway/maven-android-plugin/pull/205 我不明白我应该把那个新类放在哪里......
    • 我怀疑像我这样的 Windows 用户,即使使用 mklink,也无法将软链接附加到 ANDROID_HOME,因此注定要失败......
    • 这里是windows版本: mklink aapt.exe ..\build-tools\android-4.2.2\aapt.exe mklink /D lib ..\build-tools\android-4.2.2 \lib mklinkaidl.exe ..\build-tools\android-4.2.2\aidl.exe
    • 请记住,正如其他答案所指出的,这已在 Android Maven 插件的最新版本 (>3.5.3) 中得到修复。
    【解决方案2】:

    更新:

    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

    【讨论】:

    • 版本 3.5.3 不起作用。我在运行 3.5.3 时遇到了同样的问题,我还没有尝试过 3.5.4 或 3.6.0。
    【解决方案3】:

    如果您使用的是 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
    

    【讨论】:

    • 这解决了我的问题(现在)。现在我们只需要等待 android maven 插件支持新结构。
    【解决方案4】:

    我遇到了同样的问题。最后我设法在两个小时后解决了这个问题。为了简单起见并在 5 分钟内解决问题,我列出了以下步骤

    第 1 步 - 在 Eclipse 中,使用 beta 版本链接将您的 Android Maven 插件 更新到 0.4.3.2013 http://rgladwell.github.io/m2e-android/updates/master/

    第 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'

    希望对你有帮助

    【讨论】:

      【解决方案5】:

      我也有类似的问题。

      通过以下步骤解决:

      1) 升级 maven 到 3.1.1 2) 使用 android-maven-plugin 3.6.1 pr 更大 [我使用 3.8.0] 3) 使用 maven-dependency-plugin 2.8

      如果您想针对最新的 Android SDK [ex : 4.3] 进行构建,请执行以下附加步骤 - 4) 使用命令 mvn install:installFile 安装 android.jar 的本地副本。 5) 设置 18

      希望这会有所帮助。

      【讨论】:

        【解决方案6】:

        我使用的是 macOS 10.14,就我而言:

        我从AAPT下载Android打包工具,然后将所有文件复制到
        $ANDROID_HOME/platforms/$SDK/tools/


        不要提醒使用您的真实姓名 SDK 更改 $SDK 以用于实例 android-29

        【讨论】:

          猜你喜欢
          • 2013-09-26
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2017-02-05
          • 1970-01-01
          • 2013-05-11
          相关资源
          最近更新 更多