Ionic cordova build

333 views Asked by At

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

2

There are 2 answers

2
guardezi On

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
0
Osei Fortune On

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