0

I have issues with cordova and ionic. When I start a project only with Cordova I can build and emulate Android.

$ cordova build android && cordova emulate android

But, if I create a Ionic project. When I try build and emulate the console show me this message:

Running command: /home/juanobrach/moonpicker/Ionic/test1/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/juanobrach/moonpicker/Ionic/test1/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/juanobrach/moonpicker/Ionic/test1/platforms/android/cordova/build: Command failed with exit code 2
at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:131:23)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:743:16)
at Process.ChildProcess._handle.onexit (child_process.js:810:5)

I'm really so confused about it

juanObrach
  • 158
  • 1
  • 5
  • 14
  • Is the `ANDROID_HOME` environment variable set for your user? While I don't know why plain Cordova can detect it and Ionic can't, this is the core of the error. – vzsg Jun 08 '15 at 20:32
  • Me too. I don't know why... The ANDROID_HOME is correctly configure. I know this becouse I can run "android" command in my bash. And when I write ANDROID_HOME the console write me the path of my Android sdk folder. Maybe this is a bug for Ionic. Not for my environment. – juanObrach Jun 09 '15 at 02:56

2 Answers2

0

you need set the enviromental variables

in ubuntu try this this directory is where are your android sdk

export ANDROID_HOME=PATH_ANDROID_SDK

export PATH=$PATH:$ANDROID_HOME/platform-tools:$ANDROID_HOME/tools
guardezi
  • 171
  • 1
  • 8
  • OK, thanks Guardezi. I did that . But I'm not sure what is the default bash config file . I have : .bashprofile ; .bashrc ; .profile. – juanObrach Jun 14 '15 at 02:45
  • http://stackoverflow.com/questions/415403/whats-the-difference-between-bashrc-bash-profile-and-environment – guardezi Jun 15 '15 at 01:45
0

You should add it to your .bashrc file located in /home/juanobrach then restart your computer or run

source /home/juanobrach/.bashrc

export ANDROID_HOME=PATH/ANDROID_SDK

export PATH=$PATH:$ANDROID_HOME/platform-tools:$ANDROID_HOME/tools
Ryan K
  • 3,985
  • 4
  • 39
  • 42
Osei Fortune
  • 831
  • 6
  • 12