StudioWorks
StudioWorks

Reputation: 493

Failed to find 'ANDROID_HOME' environment variable. Try setting setting it manually. Only in Eclipse though

When I try to run a .sh script in ant, inside eclipse, containing the the code

#!/bin/bash
ionic resources android
ionic build android
ionic run android

in it I get the error:

1mError: Failed to find 'ANDROID_HOME' environment variable. Try setting setting it manually. 
Failed to find 'android' command in your 'PATH'. Try update your 'PATH' to include path to valid SDK directory.

But when I run the .sh myself in bash there's no errors. I've set my EXPORTS in .bashrc and in /etc/profile

Here's the ant portion:

<target name="prepare-to-build-app" >
    <exec executable="/bin/bash">
        <arg value="call-ionic-commands.sh"/>
    </exec>
</target>

What could be the error?

Upvotes: 0

Views: 104

Answers (1)

Lightbeard
Lightbeard

Reputation: 4131

I didn't find a solution, but spent a lot time researching things, so maybe this will be useful.

I think the problem fundamentally is that Eclipse is launched without the environmental variable in its context. This could be because its launched with a different user. The directions for setting ANDROID_HOME globally depend on your OS.

I looked at the eclipse.ini docs and didn't see an intuitive way to launch with an added environmental variable — in this case ANDROID_HOME.

I looked at the standard eclipse ant plugin. I was hopping to find an "Environment" tab somewhere in the eclipse run config or Window >> Preferences, but had trouble finding the settings for ant in my Eclipse version (Neon for Web Development).

Upvotes: 1

Related Questions