Reputation: 4962
I am new to Cordova and I am trying to build my project, which was previously working. I believe I have a bug. I am not very experienced with the terminal so I don't know how to resolve this. I have tried uninstalling and reinstalling cordova, as well as updating it with no success. Here is my error:
[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: /Users/joshuaoconnor/Desktop/PBBars/platforms/android/cordova/build: Command failed with exit code 2
You may not have the required environment or OS to build this project
Error: /Users/joshuaoconnor/Desktop/PBBars/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: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)
and here is the full image of the terminal
Upvotes: 0
Views: 260
Reputation: 4962
I was able to figure an answer out on my own. Coming from a complete beginner with no experience with bash profile, I was lost with your instructions (no offense). To fix this issue, learn how to edit your PATH environment variables. I used this tutorial (http://hathaway.cc/post/69201163472/how-to-edit-your-path-environment-variables-on-mac) which showed how to do it with textedit. After I learned how to edit my PATH variables, I added
export ANDROID_TOOLS="/Users/joshuaoconnor/Documents/sdk/tools"
export ANDROID_PLATFORM_TOOLS="/Users/joshuaoconnor/Documents/sdk/platform-tools"
to my BASH profile. Sithys and Logains answers did not work for me.
Upvotes: 0
Reputation: 4364
Look for the local.properties
file and add the correct path to your sdk sdk.dir=/home/somewhere/android-sdk/sdk
I would suggest to generate the project using cordova but build it using Android Studio, since you will probably want to tune one or two things on your android project anyway.
EDITED:
It seems you are on windows, so a quick way would be to set an Environment Variable called ANDROID_HOME
pointing to the directory where you downloaded the android sdk as per the Cordova documentation
Either that or the steps stated on the documentation:
To modify the PATH environment on Windows 7:
Click on the Start menu in the lower-left corner of the desktop, right-click on Computer, then select Properties.
Select Advanced System Settings in the column on the left.
In the resulting dialog box, press Environment Variables.
Select the PATH variable and press Edit.
Append the following to the PATH based on where you installed the SDK, for example:
;C:\Development\adt-bundle\sdk\platform-tools;C:\Development\adt-bundle\sdk\tools
Upvotes: 0
Reputation: 3783
Your running in a standard "beginners" issue by using cordova or phonegap - but no problem, we are here to help you ;-)
The Terminal tells you, that:
ANDROID_HOME is not set and "android" command not in your PATH.
So, you $PATH
is a SystemVariable
which "saves" pathes to important files and folders. All files, which are part of the SystemVariable $PATH
can be called via your Terminal. So because i don't know, which OS you are using, i'm going to post two solutions. One for each, mac and windows.
Before you start: The PATH
is a SystemVariable
which is needed as it is. Another folder can be added by a :
which seperates the single folders and pathes inside your PATH
. If you do anything wrong there, your system may never work correct again without reinstalling it - be carefull and do not delete any of the PATHs
content which is already there.
So you need three things in your Path
:
%ANDROID_HOME%
tools
platform-tools
$PATH
?echo $PATH
on a macecho %PATH%
on windowsPATH
Variable on WindowsSystem properties
.advanced
tab.Environment Variables
.System variables
you're going to find the Path
which can be edited over there. PATH
Variable on Mac OS X Yosemiteterminal
and go on like this:export PATH=$PATH:new/dir1/:dir2:/dir/path/new
This changes will be loaded after a reboot - to apply them immediatly after you changed it, save and close your file and type source $HOME/.bash_profile
.
If you have any further questions, let me know - i'm going to edit my answer than.
By the way: There is a great Documentation on how to install Android-Platform on Windows machines. It can be found here, inside the Apache Cordova Docs -> Android - Shell-Tools Guide
Upvotes: 1