Could not find tool aapt. Please provide proper Android SDK directory path as configuration parameter

馋奶兔 提交于 2019-12-03 06:50:12

问题


I am trying to build a android project using maven. But when I run : mvn clean install I get the following error:

Execution default-generate-sources of goal com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.4.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 . As an alternative, you may add the parameter to commandline: -Dandroid.sdk.path=... or set environment variable ANDROID_HOME. -> [Help 1]

I have set my ANDROID_HOME to the sdk directory. What can be the problem here?


回答1:


In the last release of android sdk directory structure has changed. Build tools like aapt or dex has been moved from platform-tools to build-tools directory. Support for new directory structure was added in maven-android-plugin version 3.6.0 but you use version 3.4.1. Changing plugin version to 3.6.0 in pom.xml must help. Here is snippet from my pom.xml:

        <plugin>
            <groupId>com.jayway.maven.plugins.android.generation2</groupId>
            <artifactId>android-maven-plugin</artifactId>
            <version>3.6.0</version>
            <configuration>
                <androidManifestFile>src/main/other/AndroidManifest.xml</androidManifestFile>
                <resourceDirectory>src/main/resources</resourceDirectory>
                <sourceDirectory>src/main/java</sourceDirectory>
                <sdk>
                    <platform>17</platform>
                    <path>/opt/android-sdk/</path>
                </sdk>
                <manifest>
                    <debuggable>true</debuggable>
                </manifest>
            </configuration>
            <extensions>true</extensions>
        </plugin>



回答2:


If you are using android version 17, you might want to try this documented workaround (i.e. I did not find it myself).

cd <android-sdk>/platform-tools
ln -s ../build-tools/17.0.0/aapt aapt
ln -s ../build-tools/17.0.0/lib lib



回答3:


The correct solution is documented in the changelog for version 3.6.0

Just add the sdk platform configuration to the Android Maven Plugin like so

<configuration>
  <sdk> 
    <platform>17</platform>
   </sdk>
</configuration>



回答4:


in your pom.xml file,specify the path to your android sdk

        <plugin>
            <groupId>com.jayway.maven.plugins.android.generation2</groupId>
            <artifactId>android-maven-plugin</artifactId>
            <version>3.5.1</version>
            <extensions>true</extensions>
            <configuration>
                <sdk>
                    <path>${ANDROID_HOME}</path>
                    <platform>16</platform>
                </sdk>
            </configuration>
        </plugin>



回答5:


If android sdk version above 21, just add %ANDROID_HOME%/build-tools to to environment variable PATH of your system.

to "Nemin Shah" -- copy files is not such good idea.




回答6:


I get stuck with the same problem. Finally i managed to resolve the issue after two hours. To make it simple and resolve the issue in 5 minutes i listed the steps below

Step 1 - In Eclipse update your Android Maven Plugin to 0.4.3.2013 using the beta release link http://rgladwell.github.io/m2e-android/updates/master/

Step 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>

It will solve the following issues

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

Could not find tool 'aapt'

Hope it helps



来源:https://stackoverflow.com/questions/16927306/could-not-find-tool-aapt-please-provide-proper-android-sdk-directory-path-as-co

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!