2

I set both ANDROID_HOME and PATH for tools.

my .bashrc ends with

export PATH="$PATH:/home/toskan/dev/android-sdk-linux/tools:/home/toskan/dev/android-sdk-linux/platforms"
export ANDROID_HOME=/home/toskan/dev/android-sdk-linux

if I echo $PATH i get

$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/toskan/dev/android-sdk-linux/tools:/home/toskan/dev/android-sdk-linux/platforms

if I echo $ANDROID_HOME

I get

$ echo $ANDROID_HOME 
/home/toskan/dev/android-sdk-linux

When I run $ sudo ionic build android

I get

toskan@mycomp:~/IdeaProjects/myappmaster$ sudo ionic build android
Running command: /home/toskan/IdeaProjects/myappmaster/hooks/after_prepare/010_add_platform_class.js /home/toskan/IdeaProjects/myappmaster
add to body class: platform-android
Running command: /home/toskan/IdeaProjects/myappmaster/hooks/after_prepare/020_remove_sass_from_platforms.js /home/toskan/IdeaProjects/myappmaster
Running command: /home/toskan/IdeaProjects/myappmaster/platforms/android/cordova/build
    [Error: ANDROID_HOME is not set and "android" command not in your PATH. You must fulfill at least one of these conditions.]
ERROR building one of the platforms: Error: /home/toskan/IdeaProjects/myappmaster/platforms/android/cordova/build: Command failed with exit code 2
You may not have the required environment or OS to build this project
Error: /home/toskan/IdeaProjects/myappmaster/platforms/android/cordova/build: Command failed with exit code 2
at ChildProcess.whenDone (/usr/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:134:23)
at ChildProcess.emit (events.js:110:17)
at maybeClose (child_process.js:1015:16)
at Process.ChildProcess._handle.onexit (child_process.js:1087:5)

ANDROID_HOME is set and the command in the commandline android

opens the android package manager

what am I missing?

Lucifer
  • 29,392
  • 25
  • 90
  • 143
Toskan
  • 13,911
  • 14
  • 95
  • 185
  • You are on linux system, so have you given execution permission to relative folder ? – Lucifer Aug 11 '15 at 10:23
  • I just checked, `-rwxr-xr-- 1 toskan root 3498 Jun 17 22:42 android` for the android file. All other files have the same rights. Should be fine?! – Toskan Aug 11 '15 at 10:41

1 Answers1

1

the problem was indeed the following:

sudo doesn't read the PATH, it has it's own path that gets reset for security reasons.

You can change that path in the file

/etc/sudoers

there is the sudo own PATH

or something see this

sudo changes PATH - why?

Community
  • 1
  • 1
Toskan
  • 13,911
  • 14
  • 95
  • 185