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
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.
What do i need in my Path? (especially for Cordova/PhoneGap now)
So you need three things in your Path:
%ANDROID_HOME%
tools
platform-tools
How can i see my actual $PATH?
echo $PATH on a mac
echo %PATH% on windows
How to set up the PATH Variable on Windows
Select your Computer from the Start Menu.
From the Contextmenu select System properties.
After that select the advanced tab.
In that section you click on Environment Variables.
So in the section System variables you're going to find the Path which can be edited over there.
How to set up the PATH Variable on Mac OS X Yosemite
Open your terminal and go on like this:
vi $HOME/.bash_profile
Add a line there with this content:
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
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
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.
I'm running android on a Bamboo server hosted on a Mac OS (Yosemite). I have set the path to android_sdk, both in bash_profile and in /etc/path. Checking that:
echo $ANDROID_HOME
> /Applications/Android/sdk
But when running the build I get the following error:
java.lang.RuntimeException: SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.
My problem is that this will be run from different type of machines, a linux and a MAC OS, so the path might vary. So defining a path in as an Environmental variable is not an alternative, since it might vary for the different operating system. I don't want to create separate builds for different machines.
I also haven't found any alternativ to set the variable as a capability for the bamboo agent, maybe there is?
Any suggestions how to solve this? Can I specify it in gradle somehow? Checking in local.properties is not an alternative.
In Creation of task for the plan, just provide the android sdk location (on CI server) in Environment variables. Check the screen shot attached, in my case it was placed at : "ANDROID_HOME="/Users/{your user}/Library/Android/sdk"
I have heard before that if the problem has to do with Gradle, configuring the ANDROID_HOME maybe won't work. Here is a solution that is usually working for projects on Android Studio...
In your project's directory add a file named local.properties. Then add the following line in there:
sdk.dir=/Applications/Android/sdk
This file is usually created automatically generated by Android Studio. It also has the following comments in it:
This file is automatically generated by Android Studio.
Do not modify this file -- YOUR CHANGES WILL BE ERASED!
This file should NOT be checked into Version Control Systems,
as it contains information specific to your local configuration.
Location of the SDK. This is only used by Gradle.
For customization when using a Version Control System, please read the
header note.
Specifically, on Windows 7 Pro SP1, it uses C:/Users/Alan/{.android,.AndroidStudio,.gradle}. I want it to use S:/Android/{SDK_Home,SDK_Root}/{.android,.AndroidStudio,.gradle}.
I have tried setting environment variables: ANDROID_SDK_HOME = S:\Android\SDK_Home and ANDROID_SDK_ROOT = S:\Android\SDK_Root. But it makes no difference. This persists after uninstalling Studio 1.0 and all files and folders and creating blank ones appropriately and installing and re-installing Studio 1.1.0.
The install does use the Home and Root folders to store about 3 GB of files (as I made a setting in the Install process), but it still puts an additional about 300 MB in the User directory and it doesn't put .gradle on the S drive as I would like. The User directories continue to grow as Android is used. It seems to not use C:\Users\Alan\AppData\Local anymore (thank goodness for small favors). I can't have any space taken on the C drive as it is already too full, especially if AS is growing the space it uses.
Robert suggests running a bat file to start the Studio, but it is not clear how to start the studio from a shell. I did see instructions on the Android developer site for starting an app from a shell, but not the studio. Running tools/android.bat starts the SDK Manager but not Studio. He says to set the environment variables in some bat file but they are already set in the operating system.
In any case, that doesn't solve the problem of Android Studio ignoring the settings it asks of the user during installation and ending up eating space in the C drive when the user has explicitly asked for this to not happen.
I've tried searching with terms like "move .AndroidStudio folder" and "Android Studio environment variables", but it seems to almost all be talking about the Java variable (which works fine).
Since I'm just starting an Android project I don't mind wiping and re-installing as needed.
This a year later, and thus for a different version of studio (2.2), but here's the answer. Below, the new user and/or config folder will have a full path of C:\new.
1) Copy the idea.properties file (which can be found either in the .AndroidStudio folder or in studio's /bin) to C:\new\idea.properties. Next, set the STUDIO_PROPERTIES environment variable to that location (STUDIO_PROPERTIES = C:\new\idea.properties).
2) Repeat step one for studio.exe.vmoptions or studio64.exe.vmoptions (probably the second one if you're developing in 64-bit), this time setting an environment variable called STUDIO_VM_OPTIONS to that file's location.
3) Open your new copy of idea.properties and set idea.config.path and idea.system.path to C:/new/config and C:/new/system respectively (there should be a template for both near the top that's commented out -- also note the forward slashes).
4) Set ANDROID_SDK_HOME and GRADLE_USER_HOME to C:\new
5) Set ANDROID_SDK_ROOT to the root of your sdk installation, if that's non-standard.
Note that a .AndroidStudio2.2\system folder still gets created in your user folder, but it does not seem to be used.
This answer was compiled by combining this blog post with this page from the Android Studio docs.
I'm working with KonyOne Studio to build and test apps. The Android SDK is located in C:\Android\adt-bundle-windows-x86_64-20130729\sdk and the emulator is located at C:\Android\adt-bundle-windows-x86_64-20130729\sdk\tools\emulator.exe. When I try to run apps, I get the error:
Windows cannot find 'emulator.exe'. Make sure you typed the name
correctly, and then try again.
When I just run the emulator.exe executable, I get a quick cmd screen and it disappears as quick as it appeared. Nothing shows up in my task manager.
I've set the following environment variables:
JAVA_HOME: C:\Java\jdk1.6.0_32
PATH: C:\Java\jdk1.6.0_32;D:\Users\SIMONSJP.GROUPINFRA\AppData\Roaming\npm;
C:\KonyOne\ImageMagick;C:\apache-ant-1.9.2\bin;C:\Java\jdk1.6.0_32\bin;
C:\Android\adt-bundle-windows-x86_64-20130729\sdk\platform-tools;
Ofcourse the above is without spaces. I don't understand why the emulator doesn't run. Can anyone figure out why it isn't working?
Your path variable only includes platform-tools. It needs to include the path to the emulator too.
Two ways:
Copy the emulator.exe to platform-tools
add the tools folder to path variable.
Extract your sdk zip at some other place, copy tools directory, replace it with your actual sdk tools folder contents.
Restart eclipse if required...
This worked for me.Hope same happens with you too...
I just downloaded and installed Android Studio. For whatever reason, it won't open. I've tried running it as administrator, but that doesn't seem to work either. I've also tried uninstalling and reinstalling, but I'm still having this same problem.
On windows open task manager and check if android studio is there.
End the task and start the app again it works like a charm
Figured it out! I'm sure someone will run into this in the future, so here goes.
Even though it found my JDK during installation, it wasn't able to find it when I was trying to open it, for some reason. Simple fix. Add a JDK_HOME environment variable to your system variables. It should contain the path to your JDK's ROOT directory. i.e. c:\Program Files\Java\jdk1.7.0_21\
For me this technique works
Hover on icon, then hover on app
Press right click and select maximize
This link http://tools.android.com/knownissues lists another cause for the launcher malfunctioning.
I quote the link here:
"
On some systems the launcher script does not find where Java is installed. Workaround is to set a variable indicating the location of Java [b/55281]:
Open Start menu > computer > System Properties > Advanced System Properties
In the Advanced tab > Environment Variables, add new system variable JAVA_HOME that points to your JDK folder, for example C:\Program Files\Java\jdk1.7.0_21.
Another issue we found is that the launcher script uses an option that is unknown to Java on some system [b/55267]
Open the installation folder of Android Studio (e.g. C:\Programs Files\Android\android-studio, or C:\Users\\AppData\Local\Android\android-studio) and find the "bin" directory in there.
Open a "cmd.exe" (command prompt), cd to the android-studio\bin folder and run "studio.bat". You will most likely see an error: for example b/55267 is about the option -XX:+UseCodeCacheFlushing not being recognized. Report the error, remove the line from the studio.exe.vmoptions or studio64.exe.vmoptions and it should now work.
Apologies for this weak launcher."
OS: Windows 10 64bit
Need to delete below folder and try launch Android Studio again.
C:\Users\your_user_name\AppData\Roaming\Google\AndroidStudio4.1
Source: developer android
I am Installing Android Studio 4.1.1 in my Windows 10 and trying to open as normal as well run as administration both ways but did not open as regular.
When I saw in Task Manager then it was run as a background process then simply I was Endtask it in that background process and re-open. It works for me...!!!
Just add a JDK_HOME variable with the path of your JDK as value and start the IDE again. That's the only thing to do, hope this closes the other questions.
Windows 7 user:
I tried all the above ideas ( adding JDK_HOME, JAVA_HOME environment variables), but the final trick was to run as admin.
If that fails, try "where java" in cmd.exe.
If it lists c:\system32\java.exe first, then rename the file.
(i) Open the folder where android-studio is installed. (C:\Program Files (x86)\Android\android-studio)
(ii)- Right click on the android-studio folder and scroll to properties.
(iii)While in Properties window, click on Security.
(iv)Click the Edit Button
(v) Select User/Admin...or others
(vi)Check "Allow" in front of "Full control"
(vii) Either Apply or Press OK
....At this point you have to wait for it to install....Enjoy!!!
And I use Window 8...!!! So same thing applies to Window 7...wonder why the security on it...
I am on Windows 8 64 bit machine.
I already had JDK installed and jdk.1.7.0 folder was present in C:\Program Files\Java. But path for that folder didn't work. You must have jdk.1.7.xxx folder present on your machine and give that folder as JDK_HOME in Environment variable.
You can take latest JDK version from here
Make sure to choose Windows x64 version. Install JDK and then set your path. For those who are not sure how to set path in Windows 8, I have got following screenshots.
Go to bottom right corner. Click on Settings. Click on PC Info.
Click on Advanced System Setting link on left side.
Click on Environment Variables button. A Winodw will open with 2 listboxes. Click on New button below System variables listbox. New Window will pop up. Provide name as JDK_HOME and path as your path like "C:\Program Files\Java\jdk1.7.0_55". No need to take bin folder into the path.
None of the above mentioned solution worked for me. And there is no studio.bat file in bin directory.
So, I downloaded a 32-bit android-studio for my system (as it is 32bit) from here (official website) and it worked!
PS: The link might be broken in the future, just google for the 32 bit android studio.
(After wasting half a day on it, finally, I got it running)
I am running it on Windows 8.1. Also, I had JDK 1.7.0_13.
I tried the following:
Open Start menu > Computer > System Properties > Advanced System Properties In the Advanced tab > Environment Variables
Add new system variable JAVA_HOME that points to JDK folder, C:\Program Files\Java\jdk1.7.0_13\
Just to be on the safer side, also add new system variable JDK_HOME that points to JDK folder, for example, C:\Program Files\Java\jdk1.7.0_13\
Append new PATH in system variable that points to JDK folder, C:\Program Files\Java\jdk1.7.0_13\
But still it didn't work. Then it struck me that might be, my Java version is old. I downloaded the latest version from here.
I uninstalled JDK 1.7.0_13 and installed version 8 i.e. JDK 1.8.0_131.
Now do all the above steps but, replace the path with C:\Program Files\Java\jdk1.8.0_131\ OR whichever your latest version is.
Success!! Now it works.
In my case, I have existing projects and during trying the opening Android Studio, it just showed me the name of the project.
The thing I did was changing the name of that project and forcing Android Studio to ask me to choose which project at the beginning.
In my case, it was a windows related bug. Android Studio was configured properly and working like a charm, but it was opening in the second disconnected windows.
My solution was to press [Win] + Tab and then choose Android Studio on half of the screen so that it readjusts. Finally, I maximized it and it opened it in the correct screen.
I was able to resolve the same issue by refer to the solution provided in Android Developer Portal,
Studio doesn't start after upgrade
If Studio doesn't start after an upgrade, the problem may be due to an invalid Android Studio configuration imported from a previous version of Android Studio or an incompatible plugin. As a workaround, try deleting (or renaming, for backup purposes) the directory below, depending on the Android Studio version and operating system, and start Android Studio again. This will reset Android Studio to its default state, with all third-party plugins removed.
For Android Studio 4.1 and later:
Windows: %APPDATA%\Google\AndroidStudio Example: C:\Users\your_user_name\AppData\Roaming\Google\AndroidStudio4.1
macOS: ~/Library/Application Support/Google/AndroidStudio Example: ~/Library/Application Support/Google/AndroidStudio4.1
Linux: ~/.config/Google/AndroidStudio and ~/.local/share/Google/AndroidStudio Example: ~/.config/Google/AndroidStudio4.1 and ~/.local/share/Google/AndroidStudio4.1
In my case executing these in the command line worked after ending the Android Studio process in the task manager:
net stop winnat
net start winnat
Check the log file in :
C:\Users\<yourid>\.AndroidStudio<version>\system\log\idea.log
It might give you some clue.
You don't have to reinstall the Android Studio. In my case, I just deleted "C:\Users\User.AndroidStudio3.5" folder. Then Android Studio is opened. The folder contains just personel settings such as your ide theme darcula etc.
I invalidated cache and restartI deleted the Android studio version folder which was C:\Users\User.AndroidStudio3.5 for me and it worked like charm.
What worked for me was simply rebooting the computer. I'm certain that logging off and logging in will work to so the environment variables can refresh on profile level after installation.
Change the JAVA_HOME system environment variable to C:\Program Files\Android\Android Studio\jre
The direct path to installed java may not work sometimes due to version conflict.
I had Android studio crash on my machine crying about ram. Then it just wouldn't start again. Restarting th ecomputer wouldn't help and I know it has nothing to do with Java.
What ended up fixing it was runing Android Studio trough the Start Menu, or the instalation folder and not the pinned icon ...
Make sure you are not using two Languages (Hindi + English) as input method because android studio install required some time stamp and suppose you are using Hindi language that time and letters will not match at the time of opening
Solution is - select primary Language as English while installing Android Studio.
To change steps
press Windows
search word language
remove Hindi Language
then install Android Studio
I edited studio.bat file.
I added actual jdk placement to SET JDK= line at the beginning of file:
SET JDK=C:\\\Program Files\\\Java\\\jdk1.8.0_151
You must upgrade to 4.0.1 version!
The same problem happened with me. Actually my C drive wasn't full still I wanted to install android studio in D drive. The problem was resolved when I deleted it and again installed android studio.
Install it in C drive (You don't have to do anything for that. Actually, just click next...next.. next.. while installing and you are done.
)
Zuhair Naqi's solution is good, but in my case I don't have the option to maximize. So I found another method, because in my case the Android Studio (Bumblebee) does not open every time the windows was updated.
Select right click on the android studio icon, and open some recent project.
A new window will open with the recent project correctly.
You close the window that you couldn't see, and from there you can open projects normally.
I was able to solve it by going to control panel and uninstalling android studio, then restarting the computer so that any running instances would close. Next I deleted the folder
C:\Program Files\Android\Android Studio
Re-installed everything, and everything was working fine.