3

I've tried every advertised method to specify the path to my Android SDK when trying to build an Android app using the android-maven-plugin, and nothing works. No matter what I do, when I run

mvn clean install

I get

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

I set env variable ANDROID_HOME to point to the root directory of the SDK, and exported it. Then

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

does not work. (and I have API 19 installed in the SDK)

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

does not work

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

Does not work. And

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

Does not work.

I've also tried appending the tools, platform-tools, and build-tools/19.1.1 directories in the SDK to $PATH, and this does not work either. The aapt tool is available on my path, but the maven plugin refuses to see it. I searched the web, and the only advice I see is to do what I've done.

What am I missing? I'm doing this on an OSX system.

MidnightJava
  • 1,927
  • 2
  • 18
  • 38

1 Answers1

1

Older versions of Android Maven Plugin might not work with latest SDK. For example support for SDK 22 was added in version 3.6.0. Check changelog.

3.6.0

The plugin has been updated to work with the SDK release 22.0. 21.1 works on the CI server. It might or might not work for older versions.

You don't need to configure ANDROID_HOME inside pom.xml, my working configuration looks like this:

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

Configure ANDROID_HOME properly, for me this points to

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

Make sure it is properly configured, before invoking maven. For example simply run echo $ANDROID_HOME

Community
  • 1
  • 1
MariuszS
  • 30,646
  • 12
  • 114
  • 155
  • Thanks. I believe that's exactly what I'm doing. Configuring ANDROID_HOME inside the pom was just one of several things I tried when doing what I thought was the right thin wasn't working. I have ANDROID_HOME pointing to the rood directory of the android sdk. I verify it with echo before invoking maven. – MidnightJava Jan 27 '14 at 15:23
  • @MidnightJava What is the version of `android-maven-plugin`? Execute maven build with -X and post full error. – MariuszS Jan 27 '14 at 15:25
  • Per answer given in OP: Version 3.8.2 of android-maven-plugin and maven 3.1.1 was the right incantation. – MidnightJava Jan 27 '14 at 16:04
  • 1
    Changelog now here http://simpligility.github.io/android-maven-plugin/changelog.html – Vlad May 26 '18 at 13:42