Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ionic can't run ionic platform android

I am starting to follow this demo for learning the ionic framework.

I made it to the point where it suggests that I type in ionic platform android. When I type that, I get this error:

C02FF724DF91:todo jcorser$ ionic platform android
Creating android project...

/Users/jcorser/.cordova/lib/npm_cache/cordova-android/3.6.3/package/bin/node_modules/q/q.js:126
                    throw e;
                          ^
Error: ANDROID_HOME is not set and "android" command not in your PATH. You must fulfill at least one of these conditions.
    at /Users/jcorser/.cordova/lib/npm_cache/cordova-android/3.6.3/package/bin/lib/check_reqs.js:158:19
    at _fulfilled (/Users/jcorser/.cordova/lib/npm_cache/cordova-android/3.6.3/package/bin/node_modules/q/q.js:798:54)
    at self.promiseDispatch.done (/Users/jcorser/.cordova/lib/npm_cache/cordova-android/3.6.3/package/bin/node_modules/q/q.js:827:30)
    at Promise.promise.promiseDispatch (/Users/jcorser/.cordova/lib/npm_cache/cordova-android/3.6.3/package/bin/node_modules/q/q.js:760:13)
    at /Users/jcorser/.cordova/lib/npm_cache/cordova-android/3.6.3/package/bin/node_modules/q/q.js:821:14
    at flush (/Users/jcorser/.cordova/lib/npm_cache/cordova-android/3.6.3/package/bin/node_modules/q/q.js:108:17)
    at process._tickCallback (node.js:419:13)
    at Function.Module.runMain (module.js:499:11)
    at startup (node.js:119:16)
    at node.js:906:3
Error: /Users/jcorser/.cordova/lib/npm_cache/cordova-android/3.6.3/package/bin/create: Command failed with exit code 8
    at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:135:23)
    at ChildProcess.emit (events.js:98:17)
    at maybeClose (child_process.js:755:16)
    at Process.ChildProcess._handle.onexit (child_process.js:822:5)

I am on Mac OSX. I have developed two android apps before using Android Studio. I also followed the suggestion for OSX on the manual $ export JAVA_HOME=$(/usr/libexec/java_home) but this did not fix the problem.

like image 330
johncorser Avatar asked Sep 22 '14 20:09

johncorser


People also ask

How do I run an Ionic app on Android?

To run your app, all you have to do is enable USB debugging and Developer Mode on your Android device, then run ionic cordova run android --device from the command line. Enabling USB debugging and Developer Mode can vary between devices, but is easy to look up with a Google search.


3 Answers

If you installed Android SDK via Homebrew, then the fix is this:

export ANDROID_HOME=`brew --prefix android`
like image 124
Domas Avatar answered Oct 03 '22 08:10

Domas


on macosx it will be like this

step1

open and edit the profile


    vi ~/.bash_profile

step2

the bash_profile would be like below (this is my edition)


    export ANDROID_HOME=/Users/Zam/Documents/android-sdk-macosx
    export PATH=$ANDROID_HOME/tools:$PATH

for you, it shuold use your sdk location


    export ANDROID_HOME=where your sdk location
    export PATH=$ANDROID_HOME/tools:$PATH

step3

refresh


    source ~/.bash_profile

like image 41
Zam Avatar answered Oct 02 '22 08:10

Zam


On windows set the ANDROID_HOME in System Variables

like image 34
Sandro Avatar answered Sep 29 '22 08:09

Sandro