Search code examples
javaandroidmavenm2eclipse

maven android plugin:No Android SDK path could be found


I use the maven-android-plugin version 3.3.2. When I try to build my android project I have the following exception:

org.apache.maven.plugin.MojoExecutionException: No Android SDK path could be found. You may configure it in the plugin configuration section in the pom file using <sdk><path>...</path></sdk> or <properties><android.sdk.path>...</android.sdk.path></properties> or on command-line using -Dandroid.sdk.path=... or by setting environment variable ANDROID_HOME

However environment variable ANDROID_HOME is set to android sdk path.

Can you please help me?


Solution

  • It sounds like, while the env var is available on the shell you run, it isn't available on the shell Maven runs.

    Regardless, instead of working around it, it's best to create a settings file with the property set. A minimal one would look like this (writing off the top of my head, as I don't have my settings file available now) :

    <settings>
      <profiles>
        <profile>
            <id>android-settings</id>
            <properties>
                <android.sdk.path>/path/to/android/sdk</android.sdk.path>
            </properties>
        </profile>
      </profiles>
      <activeProfiles>
            <activeProfile>android-settings</activeProfile>
      </activeProfiles>
    </settings>
    

    Throw it into your .m2 folder or set it via Eclipse in Window->Preferences...->Maven->User Settings.