14

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?

Nemin Shah
  • 301
  • 1
  • 3
  • 12

6 Answers6

39

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>
Sergey Veselov
  • 553
  • 4
  • 15
7

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
Jordan
  • 551
  • 3
  • 11
  • I found the solution. Its not the perfect one but it worked. I just copied all the files in the build-tools folder and copied in into the tools folder in the Android SDK directory. (Do not replace the existing files) – Nemin Shah Jun 05 '13 at 18:27
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>
Manfred Moser
  • 29,539
  • 13
  • 92
  • 123
1

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>
omega
  • 630
  • 1
  • 6
  • 16
  • The environment variable ANDROID_HOME is used anyway, so mentioning the path here is redundant... – dhardy Jun 13 '13 at 12:27
0

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.

arthas
  • 104
  • 1
  • 11
0

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

vinothp
  • 9,939
  • 19
  • 61
  • 103