When I do "flutter doctor" on cmd this is the error I receive:
where' is not recognized as an internal or external command operable program or batch file unable to locate git
Note that git --version gives me git version 2.28.0.windows.1
These are the things I tried
1.Reinstalling git
2.Updating Powershell to 5.0 as I run windows 7 SP1 and flutter requires Powershell 5.0 and greater
3.Tries resetting path variables
Here are my path variables.
USER ENV VAR:
C:\Program Files\MySQL\MySQL Shell 8.0\bin\;C:\Users\DELL\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\DELL\AppData\Roaming\npm;C:\src\flutter\bin
SYSTEM ENV VAR:
C:\Program Files\Java\jdk-14\bin;%PYTHON_HOME% ; C:\Users\DELL\AppData\Local\Programs\Python\Python37;C:\Program Files\MySQL\MySQL Server 8.0\bin;C:\Program Files\nodejs\;C:\Program Files\Git\cmd;C:\Program Files\Git\bin\git.exe;C:\Windows\System32 ;%systemroot%\System32\WindowsPowerShell\v1.0\
I am not able to find where exactly I am going wrong.
I am new to this.Any help would be appreciated.I have been trying this from 3 days nothing helps.
UPDATE
ADDING FLUTTER PATH TO SYSTEM VARIABLE WORKED FOR ME . Though now I have another set of issues as you can see in the image.I have android studio installed ; Have installed the dart and flutter plugin.Still I am getting the error
Make sure this path of flutter %/flutter/bin exists in the environment variable and you have restarted the terminal (maybe the system also).
Update :
Can You run flutter doctor -v using flutter_console and show us the error message:
Comparing with my enviroment variables it seems like you don't have java jdk installed, otherwise i see no problem . However i will share my variables . Another way of finding what is wrong is opening cmd in the flutter folder and lanuching flutter_console.bat inside the cmd, that way it will not close and it will show the error if there is any
USER ENV:
C:\Users\USER\AppData\Local\Microsoft\WindowsApps;C:\Windows\Microsoft.NET\Framework\v4.0.30319;C:\Users\USER\AppData\Local\Programs\Microsoft VS Code\bin;D:\flutter\bin;C:\Users\USER\.gradle\wrapper\dists\gradle-6.1.1-all\cfmwm155h49vnt3hynmlrsdst\gradle-6.1.1\bin;C:\Program Files\Java\jdk1.8.0_261\bin;C:\Users\USER\AppData\Local\Android\Sdk\tools\bin;
SYSTEM ENV:
C:\Program Files (x86)\Common Files\Oracle\Java\javapath;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;%SYSTEMROOT%\System32\OpenSSH\;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Program Files\Git\cmd
Anyone managed to solve the issue with ANDROID_HOME variable with WebStorm EAP?
I have set up the variable at my machine level, and did it at WebStorm level but does not work:
ERROR running one or more of the platforms: Android SDK not found. Make sure that it is installed. If it is not at the default location, set the ANDROID_HOME environment variable.
You may not have the required environment or OS to run this project
Any idea?
I was facing the same problem in Ubuntu 15.10. It worked nicely when I compiled the program from terminal, but not when I tried the same command from WebStorm IDE.
The solution was trivial, yet hard to find. If you start the program from the launcher (or desktop file), the environmental variables are not getting populated the same way as from the .bashrc file. That is why there was no ANDROID_HOME at all, and the PATH was also different.
The accepted answer from this thread solved my problem: My .bashrc alias not run in .desktop file
Solution for Linux:
Find the WebStorm IDE desktop file (Mine was located at ~/.local/share/applications/jetbrains-webstorm.desktop)
Edit the Exec command (Add bash -ic before the executable file: Exec=bash -ic "/path/to/webstorm/bin/webstorm.sh" %f)
If you know the path to your android sdk home from your root then what you need to do is as a root user edit the /etc/profile and add this line at the end
export ANDROID_HOME="path/to/my/sdk"
To edit the /etc/profile file you can use nano,
sudo nano /etc/profile
add the export line at the end of the file, then press ctrl+o on your keyboard to save and ctrl+x on your keyboard to close.
Then restart your computer, you have successfully added the ANDROID_HOME env variable to your OS
In Linux, one should mind the difference between a login and an interactive shell environments. The former is visible to any application in a session, the latter - only to a shell (and processes launched from that shell). The correct solution is moving your variables into a login environment (~/.profile, ~/.bash_profile etc.) and restarting a session.
Under macOS, all JetBrains IDEs explicitly load a shell environment. If some variable isn't visible to some IDE component, then it's a bug either in that component or in a code which loads the environment; both cases better be reported to http://youtrack.jetbrains.com.
edit: (aug-2016)
That question is from November 2013 (while Android Studio was still in Developer Preview mode),
Currently (AS v2.2, Aug-2016) during instalation AS asks to choose the SDK folder (or install on their default) and it automatically applies to which ever project you're opening.
That means any possible workaround or fix is irrelevant as the issue is not reproducible anymore.
original question:
we have this project with several modules that is already configured and executes correctly on another developer PC using a wrapper. I cloned the complete git submodules into my machine.
Below it's a directly print of my command line:
$ ./gradlew
FAILURE: Build failed with an exception.
* Where:
Build file '/home/budius/project_name/ActionBar-PullToRefresh/library/build.gradle' line: 1
* What went wrong:
A problem occurred evaluating project ':ActionBar-PullToRefresh:library'.
> SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 6.378 secs
$ echo $ANDROID_HOME
/home/budius/Applications/android-studio/sdk
$
so, as you can see the ANDROID_HOME is there. What else do they want? What's wrong here.
running on Ubuntu 13.04
edit:
I already created a local.properties file with sdk.dir=<path> on the project root and it works. But that makes the code harder to port across systems n build server, so the question is still open.
Anyone knows why the ANDROID_HOME is not working and what to do to make it work?
In /my_current_project/, I created a file called local.properties and put inside:
sdk.dir=/my_current_path_to/sdk
In the console I need to do:
set ANDROID_HOME=/my_current_path_to/sdk
On OSX, IntelliJ won't pick up the environment variables you set in your .bash_profile or .bash_rc etc...
Try this, substituting the value of your own sdk location:
launchctl setenv ANDROID_HOME /usr/local/opt/android-sdk
Then restart IntelliJ and Bob's your uncle.
Here is a reference to the problem, stated more generally:
https://emmanuelbernard.com/blog/2012/05/09/setting-global-variables-intellij/
In my case settings.gradle was missing.
Save the file and put it at the top level folder in your project, even you can copy from another project too.
Screenshot reference:
Hope this would save your time.
This works for me:
$ export ANDROID_HOME=/path_to_sdk/
$ ./gradlew
The Android Gradle plugin is still in beta and this may simply be a bug. For me, setting ANDROID_HOME works, but we may be on different versions (please try again with the most recent version and let me know if it works or not).
It's also worth setting the environment variable ANDROID_SDK as well as ANDROID_HOME.
I have seen issues with this on some machines, so we do create local.properties in those cases - I have also noticed that the latest version of Android Studio will create this file for you and fill in the sdk.dir property.
Note that you shouldn't check local.properties into version control, we have added it to our gitignore so that it doesn't interfere with porting the code across systems which you rightfully identified as a potential problem.
For whatever reason, the gradle script is not picking up the value of ANDROID_HOME from the environment. Try specifying it on the command line explicitly
$ ANDROID_HOME=<sdk location> ./gradlew
I faced the same issue, though I had local.properties file in my main module, and ANDROID_HOME environment variable set at system level.
What fixed this problem was when I copied the local.properties file which was in my main project module to the root of the whole project (i.e the directory parent to your main module)
Try copying the local.properties file inside modules and the root directory. Should work.
I came across the same problem when opening a cloned git repository. The local.properties file is automatically added to the .gitignore file as it is specific to the build environment of each machine and is therefore not part of the repo.
The solution is to import the project instead of just opening it after you have cloned it from git, this forces android studio to create the local.properties file specific to your machine:
File >> Import Project >>
MAC OSX:
Open up Terminal and edit the file:
~/.bash_profile
to add:
export ANDROID_HOME=~/Library/Android/sdk
export PATH=${PATH}:${ANDROID_HOME}/tools
export PATH=${PATH}:${ANDROID_HOME}/platform-tools
Run:
source ~/.bash_profile
Restart the Terminal and Android Studio
How to do it on MAC OSX:
1) Open up Terminal, and Edit: vi ~/.bash_profile If there is no file there, just add it.
2) Add (Change to YOUR USER NAME and add this):
#Java var home:
JAVA_HOME="/usr/libexec/java_home"
ANDROID_HOME="/Users/<YOUR USER NAME>/Library/Android/sdk"
3) Run source ~/.bash_profile.
4) Run echo $JAVA_HOME; echo $ANDROID_HOME;
5) If your output is:
/usr/libexec/java_home
/Users/<YOUR USER NAME>/Library/Android/sdk
So you are good.
and RESTART android studio!
And,
Make sure that you have java :)
java -version
And gradle :)
gradle --version
Copy the local.properties to root folder and run again.
This worked for me (Ubuntu):
Add ANDROID_HOME=/path/to/android-sdk to /etc/environment.
Reboot.
in windows, I set ANDROID_HOME=E:\android\adt-bundle-windows-x86_64-20131030\sdk
Then it works as expect.
When in Linux, you need to set sdk.dir.
The script uses two different variables.
I have the same problem, seems the sample code can not find the android environment, instead to try to fix that I just remove the sample code from settings.gradle and then the installation goes fine.
after that just import the project in eclipse and that's all :)
In Linux, try to run studio.sh from a terminal and set the ANDROID_HOME in this terminal. This worked for me.
If you are using windows plantform, please try run Android Studio as Administrator
Just delete the sdk.dir inside the local.preoperties file and set the ANDROID_HOME environment variable . It worked for me.
export ANDROID_HOME=/xxx/xxx/ in shell, then use it by System.env.ANDROID_HOME in gradle file.
PS: don't forget the 'export' keywords to make the ANDROID_HOME global.
Your local.properties file might be missing. If so add a file named 'local.properties' inside /local.properties and provide the sdk location as following.
sdk.dir=C:\Users\\AppData\Local\Android\Sdk
I have set the ANDROID_HOME = [PATH_OF_MY_ANDROID_SDK] to my environment variable. That solution works for me.
I have just solved the exact same issue by adding the ANDROID_HOME as a system wide variable.
In Ubuntu it should be in /etc/profile or in a shell script file in /etc/profile.d/
Then logout and login again, now Gradle should recognize the ANDROID_HOME variable.
I came across a similar problem. Somehow, I did not have a build folder in my project. By copying this folder from another project to my project I was having an issue with, this fixed this problem.
Installing Build-Tools 23.0.1 instead of 23.0.2 fixed this issue for me.
solutions:
1 add "sdk.dir=path_of_sdk"
2 execute gradlew with evn variable like following:
$ANDROID_HOME=path_of_sdk ./gradlw
You said that versioning local.properties creates problems for you. I've hacked together a script which uses android command line tool to refresh the local.properties file across the machines that are involved in the production. The android update project command, besides the local.properties produces a lot of unwanted trash (at least for me) which is the reason for all those rm commands at the end of the script.
#!/bin/bash
scname="$0"
echo "${scname}: updating local properties..."
ln -fs src/main/AndroidManifest.xml
android update project -t 24 -p "$(pwd)"
echo "${scname}: ...done"
echo "${scname}: removing android update project junk ..."
rm -v project.properties
rm -v build.xml
rm -v proguard-project.txt
rm -v AndroidManifest.xml
echo "${scname}: ...done"
This script is the first thing we run on any new machine where we code. It has to be run in the root project directory. Of course, android studio may have a GUI way of dealing with this, but I wouldn't know as I use a different editor. I also can't claim that the solution is general, but it "Works For Me" (tm).
I have faced with the same issue on Ubuntu(both local.properties and ANDROID_HOME was added), but build fail persisted. So workaround is to
add following lines
export ANDROID_HOME=/home/<user>/Android/Sdk
export PATH=$PATH:/home/<user>/Android/Sdk/tools
directly to the studio.sh script (inside /usr/local/android-studio/bin)
Maybe it will be helpful.
i encountered the same error but in my case i was cloning a project, the cloned project was built with Android API 22 which i did not install at the time(i had API 24 and 25 installed)........so i had to download the sdk tools for API 22
For Windows:
Add ANDROID_HOME to the Environment Variables:
ANDROID_HOME = C:/Users/YOUR_USERNAME/AppData/Local/Android/sdk
Add %ANDROID_HOME%\platform-tools to the PATH.
On my system (Ubuntu 20.04 after two version upgrades from 19.04) the symptoms were as if gradle (4.4.1 installed from APT repos) ignored ANDROID_HOME environment variable, while picking up the sdk.dir value from local.properties if I created one.
The reason appeared to have been that java command referred to openjdk version "11.0.7". After I installed openjdk-8-jdk package and did update-alternatives --config java to make the default java be version 8 ("1.8.0_252"), gradle started working as expected.
My issue was that directory did not exist. The env vars were set correctly, but the underlying directory did not exist. After opening AS the first time and having it create the directory, everything worked.
echo $ANDROID_HOME
/Users/x/Library/Android/sdk
$ echo $ANDROID_SDK_ROOT
/Users/x/Library/Android/sdk
$ cd $ANDROID_HOME
-bash: cd: /Users/x/Library/Android/sdk: No such file or directory
i'm on a Windows 7 Pro x64 with java jdk 7u7.
I try to install the Android SDK on my computer, but when i launch SDK Manager.exe, a dos-windows is opening and instantly closing. So i tried to launch tools/android.bat. But that didn't work, it say to me that :
"'C:\PROGRA~2\Android\ANDROI~1\tools\lib\\find_java.exe -s' isn't a external or internal command ...
ERROR No suitable java such ..."
What i have do for fix error :
Install Java 6u35
Install Java x32 and x64
Check my path
Launch in administrator
Install in C:\Dev the sdk
Install with android-sdk.zip or with android-sdk.exe
Add android directory in path
But anyone of this try was successful.
Someone can help me?
There appear to be several ways to launch the SDK Manager:
SDK Manager.exe in the root of the Android SDK.
SDK Manager.exe in sdk\tools\lib of the Android SDK.
Window -> Android SDK Manager menu in Eclipse
android.bat in sdk\tools of the Android SDK.
In my case, it looks like android.bat fails on the line:
for /f %%a in ('%java_exe% -jar lib\archquery.jar') do set swt_path=lib\%%a
As far as what that line is doing... if I manually run: "[path_to_java]java" -jar lib\archquery.jar
It successfully returns: x86_64
But when the batch file runs that same command, I don't know why but it fails with the error message:
Unable to access jarfile lib\archquery.jar
So the variable swt_path gets set to an empty string. Everything breaks down from there.
The batch file sets the correct value for the variable java_exe. Others have commonly reported this as a problem, but those workarounds weren't relevant in my case.
People have recommended commenting out the problem line by adding REM to the beginning of it, and adding a line to manually set the swt_path variable, which is a valid workaround:
REM for /f %%a in ('%java_exe% -jar lib\archquery.jar') do set swt_path=lib\%%a
set swt_path=lib\x86
BUT, the critical issue in my case is that it's choosing to load a jar file from either the lib\x86 or the lib\x86_64 folder here. At some point, things were getting confused between the BAT file error, a 32-bit JDK, and a 64-bit Android SDK.
SO, the workaround in my case was to:
Uninstall ALL versions of Java
Install the JDK
You can either use the 32-bit Android SDK and install the 32-bit JDK
Or use the 64-bit Android SDK and install the 64-bit JDK
But the "bitness" of the JDK should match the Android SDK. It appears that either of the 32-bit or the 64-bit will work on a 64-bit computer, AS LONG AS the JDK bitness matches the Android SDK bitness.
Edit "android.bat"
If using the 32-bit Android SDK/JDK, use lib\x86:
REM for /f %%a in ('%java_exe% -jar lib\archquery.jar') do set swt_path=lib\%%a
set swt_path=lib\x86
If using the 64-bit Android SDK/JDK, use lib\x86_64:
REM for /f %%a in ('%java_exe% -jar lib\archquery.jar') do set swt_path=lib\%%a
set swt_path=lib\x86_64
After doing this, I can successfully run the SDK Manager by running android.bat, or from the Eclipse menu (but still not by running either of the SDK Manager.exe files directly).
I had this answer just this week and have determined what is causing it.
When Java updates it changes the path where the executable files are stored. This means that when the SDK manager goes to look up javaw.exe it cannot find it and instantly closes.
Therefore re-installing the Android SDK will NOT solve the problem.
Neither will re-installing JAVA.
The only way to solve this problem is to correctly point to the location where JAVA is stored.
Windows has a way of doing this called an Environmental Variable.
There is a variable called PATH which stores all the directories where Windows will look for executable files.
Thus you have to to modify that PATH variable to include a path to JAVA.
By default JDK 7 has the following path:
C:\Program Files\Java\jdk1.7.0_10\bin
To edit your Environmental Variables do the following.
From the Start Menu right click on Computer and select "Properties"
This will take you to the Control Panel System Menu
On the left column look for the option "Advanced System Settings"
This will open a System Properties window
One of the tabs is named Advanced
In that there is a button that says Environmental Variables
If you search your System Variables you will see one called "Path"
Edit that variable and add the path above to include the latest Java Path.
Once you are done the SDK Manager should immediately be able to open up and you can continue updating to the latest revision of the Android SDK.
Once the updates complete don't forget to make sure your IDE (ie Eclipse) is pointing to the correct location where the SDK is stored so that it reads the latest Android SDK files. To access this setting in Eclipse, go to Window -> Preferences -> Android
This will allow you to manually set the path where the SDK is stored.
The only thing that helped me was reinstalling java into a path that did not contain any spaces, so instead of C:/Program Files to C:/Java and change the Path variable to the new value.
Hope this helps.
I had the same issue and it's most likely caused by spaces in the path names. It's known that spaces in path names and batch files don't combine well together.
You can verify that by opening a command line prompt, changing the location to %SDK%\tools\lib and running find_java.bat. You will get an batch error like
'C:\PROGRA~2\Android\Android' is not recognized as an internal or external command,
operable program or batch file.
Just install the SDK into C:\Android\SDK and the NDK into C:\Android\NDK and it will work.
This is how I finally fix it
open tools/android.bat
set java_exe=
call lib\find_java.bat
if not defined java_exe goto :EOF
replace it with your java path
set java_exe="c:\PROGRA~1\Java\jdk1.7.0\bin\java.exe"
Note:
Do not use C:\Program Files\Something it throw an error because of the space
use the short name notation C:\PROGRA~1\Something
and it will work like charm
Same issue for me SDK Manager.exe just stopping with no error message or windows event.
I fixed this with a hybrid of the already provided answers (I'm running on Win 8.1). The problem appears to be that the java.exe targeted by find_java was out-of-step with the recently installed JDK version.
for me:
<sdk> was C:\Users\Simon\AppData\Local\Android\sdk
<jdk> was C:\PROGRA~1\Java\jdk1.7.0_80\bin
I added my JDK install path to the PATH environment variable e.g. ...;C:\PROGRA~1\Java\jdk1.7.0_80\bin;...
After opening a new command window and running find_java.bat in the <sdk>\tools\lib\ folder I noticed that the java_exe env variable was set was to C:\Windows\System32\java.exe which was not what I expected.
I deleted (well renamed) the java.exe in C:\Windows\System32
I ran find_java.bat again and now the java_exe env variable was set to java_exe=<jdk>\java.exe as expected.
Then in <sdk> I could run SDK Manager.exe successfully.
Changing the JAVA_HOME from existing pointing to a JDK path to a JRE path works for me.
I'm trying to set up ANT for my Android project. According to the Android website, the command to use is
android update project -p name
Unfortunately, the command "android" is not available on my command line (Windows 7).
Can you please tell me what kind of environment variables do I have to set up? The SDK is located in C:\Program Files (x86)\Android\android-sdk, I assume I will need that.
Do I just have to extend "path" or is there the need to create new variables (something like "JAVA_HOME", but for android).
Thank you
C:\Program Files (x86)\Android\android-sdk\tools
C:\Program Files (x86)\Android\android-sdk\platform-tools
are both valuable to have on the path. I don't remember which has the android binary, but, with both, you will definitely get it. With both you will also get adb and progaurd.
And also, extend PATH don't create a new one.