android maven plugin does not get ANDROID_HOME env variable in Eclipse

20,716

Solution 1

You need to create a system variable for ANDROID_HOME, not set it in your PATH.

Solution 2

Ensure your Android SDK installation contains the libraries for the same API version you have configured on your pom.xml.

For example, if your configuration XML looks like:

<plugin>
    <groupId>com.jayway.maven.plugins.android.generation2</groupId>
    <artifactId>android-maven-plugin</artifactId>
    ...
    <configuration>
        <sdk>
            <path>${env.ANDROID_HOME}</path>
            <platform>8</platform>
        </sdk>
        ...
    </configuration>
</plugin>

then you should verify with Android SDK Manager (or directly checking on your filesystem: $ANDROID_HOME/platforms) that you have SDK API 8 installed. Of course you can also change your pom.xml to match the library installed.

Solution 3

If you are using Linux, exporting the ANDROID_HOME in the .bashrc may not work.

export ANDROID_HOME=/home/toro/etc/android-sdk-linux

For me it works only when I export ANDROID_HOME in the /etc/environment file like this:

ANDROID_HOME=/home/toro/etc/android-sdk-linux

You have to restart the computer to get it works.

You simply have to log out, and log in again for the environment variable to be applied system-wide. Optionally, you could just source it locally to test it out before you do that: $source /etc/environment

Solution 4

Setting an ANDROID_HOME variable in your .bashrc or whatever will work, but remember to export that variable so that it is available to subprocesses. Setting ANDROID_HOME with the other methods suggested here will get you through some initial errors, but without ANDROID_HOME exported your build will probably fail at some point.

Solution 5

on your command line, run:

mvn clean install -- Dandroid.sdk.path="/Applications/Android Studio.app/sdk/"

none of the other methods really worked. (setting ANDROID_HOME doesn't do anything)

Share:
20,716
Mert Buran
Author by

Mert Buran

Updated on July 09, 2022

Comments

  • Mert Buran
    Mert Buran almost 2 years

    i'm working on an Android app project and it is a Maven project. when i try to run as "maven install" this is what i get:

    "Failed to execute goal com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.1.1:generate-sources (default-generate-sources) on project android-client: No Android SDK path could be found. You may configure it in the plugin configuration section in the pom file using ... or ... or on command-line using -Dandroid.sdk.path=... or by setting environment variable ANDROID_HOME -> [Help 1]"

    if i hardcode my android_home path into pom.xml,it works fine but we use git and everyone may have different paths for android_home.why doesn't android-maven-plugin get env variable in eclipse?

    android_home env variable is in my PATH. i wrote ${env.ANDROID_HOME} in my pom.xml but it still didn't work.

    strangely,if i use terminal (mvn install) to run as maven install,it works!

    actually this is quite optional problem for me but still i want to know why this plugin does not work in Eclipse.

  • Mert Buran
    Mert Buran almost 12 years
    i'm using m2e android and sdk location is set under preferences.but thanks for answer,and your plugin.
  • Mert Buran
    Mert Buran almost 12 years
    i did "export ANDROID_HOME=path of the sdk" and added it to PATH. should i did anything else? thanks for answer.
  • RichieHH
    RichieHH over 10 years
    Generally don't set envs like this (ie you want to use from the desktop apps) in .bashrc - thats why it didnt work for you. In Debian for example I finally nailed it down to sourcing a .bash_env file for system wide ENVs from .xsessionrc - this is sourced once at login and all the exports are inherited by further terminals should you need and also available to desktop applications. Should you want these values also available in login shells (e.g ssh'ing in) you would source the same .bash_env from your .bash_profile (which is not sourced at login and has no impact on the desktop ENVs).
  • issamux
    issamux over 9 years
    no need to logout in linux Env , just do source .bash_profile . in MAC: source .profile .