This is a comment Problem with ionic in ubuntu,The solution is to add the Android home to the path
But my problem is that Even the ANDROID_HOME is already in the PATH and When i Type
$ Android
In The terminal its open Android SDK
Why ionic Can not find The android Home?!!
Update
After adding android home to the path in this terminal session
The output of echo $ANDROID_HOME is the path to android Sdk
But Still accrue the same error?!
Your global PATH relies in /etc/environment so if you edit it here it should be also available in ionic.
After you edit it you can reloaded by executing:
source /etc/environment
If you are creating a ~/.profile or ~/.bash_profile in your user's home dir that will only be loaded in a shell environment.
Make sure that your /etc/environment file looks something like this:
ANDROID_HOME=/home/eics/Android/Sdk
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools”
The error is very clear and as you wrote in the comments
echo $ANDROID_HOME
yields an empty result.
In Ubuntu, to set an environment variable globally you edit /etc/environment and there you would add
ANDROID_HOME=/path/to/android/sdk
Where you actually provide a real path, after you have done that you might need to do source /etc/environment to make it work in your current session.
If you only want to do it for your terminal, you can edit ~/.bashrc instead and add
export $ANDROID_HOME=/path/to/android/sdk
After 4 days of searching And Tried so many methods to fix this problem
I fix it with theses instructions
Install node with nvm
Never user root to install node or npm
Now its works fine for my and ionic ca see Android SDK home
export/set $Android to ANDROID_HOME to your environment variables
I am currently trying to run a test on an android emulator device with appium,
everything goes fine, appium unlocks the screen of the device but then I have this error:
[ADB] Error: Could not find aapt Please set the ANDROID_HOME environment variable with the Android SDK root directory path
I set the ANDROID_HOME varaibale im my bash file to :
export ANDROID_HOME=/home/tar/android/android-sdk-linux/
and I also set the other variables to :
export ANDROID_SDK_HOME=/home/tar/android/android-sdk-linux
export PATH=${PATH}:/home/tar/android/android-sdk-linux/platform-tools
export PATH=${PATH}:/home/tar/android/android-sdk-linux/tools
But I am still facing the same error,
does someone have an idea how to solve this please?
Thank you
First make sure that you've got the SDK installed correctly and that your path in ANDROID_HOME points to the folder containing the /bin folder.
Then try running:
source ~/.bashrc
or log-in and log-out to apply the new changes in the bash file.
You could also reuse your ANDROID_HOME variable:
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/tools
This way you don't have to change all the variables if the location of the SDK changes.
For Windows:
Open My Computer Properties
Click on 'Advanced System Setting'
Click on 'Environment Variables..'
Create Variable for User and System both
Restart the IDE.!
Please look the image below:
sudo nano ~/bash_profile and add:
export ANDROID_HOME=/home/tar/android/android-sdk-linux/
export ANDROID_SDK_HOME=/home/tar/android/android-sdk-linux
export PATH=${PATH}:/home/tar/android/android-sdk-linux/platform-tools
export PATH=${PATH}:/home/tar/android/android-sdk-linux/tools
In recent versions of Android Studio SDK, aapt is not in tools nor in platform-tools but in build-tools. You need to add it to your PATH for Appium to find it.
export PATH="$ANDROID_HOME/build-tools:$PATH"
Copy aapt.exe from build-tools to platflorm-tools. Also make sure to add ANDRIOD_HOME to sdk folder in Windows Environment variables. This solved my problem.
When I run ionic build android command in root of ionic project, I am getting this error:
FAILURE: Build failed with an exception.
Where: Script '/home/javad/Desktop/javadApp/platforms/android/CordovaLib/cordova.gradle'
line: 64
What went wrong: A problem occurred evaluating root project 'android'.
No installed build tools found. Please install the Android build tools version 19.1.0 or higher.
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
javad#javad:~/Desktop/javadApp$ ionic build android
Running command: /home/javad/Desktop/javadApp/hooks/after_prepare/010_add_platform_class.js /home/javad/Desktop/javadApp
add to body class: platform-android
Running command: /home/javad/Desktop/javadApp/platforms/android/cordova/build
ANDROID_HOME=/opt/android-sdk
JAVA_HOME=/usr/lib/jvm/default-java
Running: /home/javad/Desktop/javadApp/platforms/android/gradlew cdvBuildDebug -b /home/javad/Desktop/javadApp/platforms/android/build.gradle -Dorg.gradle.daemon=true
FAILURE: Build failed with an exception.
* Where:
Script '/home/javad/Desktop/javadApp/platforms/android/CordovaLib/cordova.gradle' line: 64
* What went wrong:
A problem occurred evaluating root project 'android'.
> No installed build tools found. Please install the Android build tools version 19.1.0 or higher.
* 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: 1.564 secs
/home/javad/Desktop/javadApp/platforms/android/cordova/node_modules/q/q.js:126
throw e;
^
Error code 1 for command: /home/javad/Desktop/javadApp/platforms/android/gradlew with args: cdvBuildDebug,-b,/home/javad/Desktop/javadApp/platforms/android/build.gradle,-Dorg.gradle.daemon=true
ERROR building one of the platforms: Error: /home/javad/Desktop/javadApp/platforms/android/cordova/build: Command failed with exit code 8
You may not have the required environment or OS to build this project
Error: /home/javad/Desktop/javadApp/platforms/android/cordova/build: Command failed with exit code 8
at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:134: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)
in ~/.profile i have:
export PATH=$PATH:/opt/android-sdk/tools
export PATH=$PATH:/opt/android-sdk/platform-tools
export PATH=$PATH:/opt/node/bin
export JAVA_HOME=/usr/lib/jvm/default-java
export ANDROID_HOME=/opt/android-sdk
$PATH is:
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/opt/android-sdk/tools:/opt/android-sdk/platform-tools:/opt/node/bin
Important issue:
in file:
/home/javad/Desktop/javadApp/platforms/android/CordovaLib/cordova.gradle | line 38:
String[] getAvailableBuildTools() {
def buildToolsDir = new File(getAndroidSdkDir(), "build-tools")
buildToolsDir.list()
.findAll { it ==~ /[0-9.]+/ }
.sort { a, b -> compareVersions(b, a) }
}
just returned /opt/android-sdk/build-tools !!!
in /opt/android-sdk/build-tools folder i have:
android-5.1 folder that extract from:
https://dl.google.com/android/repository/build-tools_r22-linux.zip
I fix this by downloading sdk package called platform-tools and buid-tools using sdkmanager. You can use sdkmanager.exe or if you are using SDK CLI, go to ~\AppData\Local\Android\sdk\tools\bin and run this command:
sdkmanager "platform-tools" "platforms;android-26"
or
sdkmanager "build-tools;27.0.3"
or both
After that you should be able to run ionic cordova run android or ionic build android.
Note: globalize sdkmanager command by adding ~\AppData\Local\Android\sdk\tools and ~\AppData\Local\Android\sdk\tools\bin to your environment variable.
For me running these three commands fix the issue on my Mac:
export ANDROID_HOME=~/Library/Android/sdk
export ANDROID_SDK_ROOT=~/Library/Android/sdk
export PATH=${PATH}:${ANDROID_HOME}/tools
export PATH=${PATH}:${ANDROID_HOME}/platform-tools
For ease of copying here's one-liner
export ANDROID_HOME=~/Library/Android/sdk && export PATH=${PATH}:${ANDROID_HOME}/tools && export PATH=${PATH}:${ANDROID_HOME}/platform-tools && export ANDROID_SDK_ROOT=~/Library/Android/sdk
To add Permanently
Follow these steps:
Open the .bash_profile file in your home directory (for example, /Users/your-user-name/.bash_profile) in a text editor.
Add export PATH="The above exports here" to the last line of the file, where your-dir is the directory you want to add.
Save the .bash_profile or .zshrc file.
Restart your terminal. Or run source ~/.bash_profile or source ~/.zshrc depending on your terminal settings.
Adding to bash process for different systems
You are missing android SDK tools. Please try the following:
android list sdk --all
android update sdk -u -a -t <package no.>
Where <package no.> is 1,2,3,n and
-u (--no-ui) # Headless mode
-a (--all) # Includes all packages (also obsolete ones)
-t (--filter) # Filter by package index
as the error says 'No installed build tools found'
it means that
1 : It really really really did not found build tools
2 : To make him find build tools you need to define these paths correctly
export ANDROID_HOME=/Users/vijay/Software/android-sdk-macosx
export PATH=${PATH}:/Users/vijay/Software/android-sdk-macosx/tools
export PATH=${PATH}:/Users/vijay/Software/android-sdk-macosx/platform-tools
3 : IMPORTANT IMPORTANT as soon as you set environmental variables you need to reload evnironmental variables.
//For ubuntu
$source .bashrc
//For macos
$source .bash_profile
4 : Then check in terminal
$printenv ANDROID_HOME
$printenv PATH
Note : if you did not find your changes in printenv then restart the pc and try again printenv PATH, printenv ANDROID_HOME .There is also command to reload environmental variables .
4 : then open terminal and write HALF TEXT '$and' and hit tab. On hitting tab you should see full '$android' name.this verifys all paths are correct
5 : write $android in terminal and hit enter
Please install the Android build tools version 19.1.0 or higher.
The following commands can update Android SDK on Ubuntu quickly and fix the above error:
android list sdk --all
android update sdk -u -a -t 19
android update sdk -u -a -t 20
I fix the error by changing the ANDROID_HOME to
C:\Users\Gebru\AppData\Local\Android\Sdk from wrong previous directory.
I know this doesn't look related, especially given the error message, but I fixed this by installing a newer version of the Android SDK Build tools.
2018
The "android" command is deprecated.
try
sdkmanager "build-tools;27.0.3"
This work for me, as #Fadhil said
In my case, the Enviroument Variable ANDROID_HOME was pointed to wrong (old) directory. I reallocated to correct one. In my case
ANDROID_HOME=F:\Program Files (x86)\Android\android-sdk
For me, the problem was that ANDROID_HOME was pointing to an old Android SDK path. After installing Android Studio, I had to update ~/.bash_profile accordingly for MAC (El Capitan)
export ANDROID_HOME="/Users/corneliusparkin/Library/Android/sdk"
Remember to re-start terminal or run this command after updating ~/.bash_profile
source ~/.bash_profile
FOR WINDOW: I have faced this type of issue. But after exploring it solved in my case. I am using window 10. just follow few steps below:
download Android SKD Manager for windows. https://developer.android.com/studio at the
end of this page. It is zip file. after extracting it will show tools directory.
Go to drive C:\ create new folder 'android-sdk'. copy tools folder and past in
C:\android-sdk
open command prompt as Administrator. Go to cd " c:\android-sdk\tools\bin ".
sdkmanager will be show here. type
skdmanager, it will show like this
[=======================================] 100% Computing updates...
after that type "sdkmanager platform-tools" it will create platform-tools directory
in C:\android-sdk
Now set System environment variables: right click on PC select
properties. system settings will popup. click on > Environment Variables. Environment
Variables will popup.
At this window System variables as like this. C:\android-sdk\platform-tools and
C:\android-sdk\tools\bin
run command to build tools sdkmanager "build-tools;27.0.3"
Also make sure java path is defined. I hope it will solve problem.
Type android on your command line and install "Android SDK Build-tools"
I Search this problem for days.... I hope it will be usefull
FINAL SOLUTION:
(I assume that you have installed Oracle-JDK and ANDROID)
open /etc/environment with
sudo nano /etc/environment
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/shoniisra/Android/Sdk/tools:/home/shoniisra/Android/Sdk/platform-tools:/home/shoniisra/Android/Sdk/build-tools:/home/shoniisra/Android/Sdk:/home/shoniisra/android-studio/bin"
JAVA_HOME="/home/shoniisra/java/jdk1.8.0_231"
ANDROID_HOME="/home/shoniisra/Android/Sdk/build-tools/29.0.2"
ANDROID_SDK_ROOT="/home/shoniisra/Android/Sdk"
ANT_HOME="/home/shoniisra/ant/apache-ant-1.9.14"
Save and exit (CTRL+o CTRL+X)
Reload file source /etc/environment
If you recently installed Android you should accept some licences
cd ~/Android/Sdk/tools/bin/
Execute sdkmanager:
./sdkmanager --licenses
Then Accept all, and Finally generate your APK
cd {yourproyect}
sudo ionic cordova build android
I have solved this issue by following steps:
Go to cordova.gradle file
(platform/android/cordovaLib/cordova.gradle)
Search for getAndroidSdkDir() method
Now simply replace System.getenv("ANDROID_HOME") with your real Android SDK path
In build.gradle script it checks if build-tools version is lower than maxVersion from Gradle configuration.
So in my case, I had environment SDK vars set, but my version was higher than allowed.
def highestBuildToolsVersion = buildToolsDirContents
.collect { new Version(it) }
// Invalid inputs will be handled as 0.0.0
.findAll { it.isHigherThan('0.0.0') && it.isLowerThan(maxVersion) }
.max()
In my case the problem was that ANDROID_HOME was pointing to ~/Library/Android/ for some reason.
The correct path is ~/Library/Android/sdk
This problem I solved with the following detail, somehow the android SDK manage installed all the dependencies and necessary files, but forget this `templates` files where is found templates> gradle> wrapper. This set of files is missing.
Path in mac
/Users/giogio/Library/Android/sdk/tools/templates
I had the same problem. I tried all the solutions on this page, but what worked for me was installing the EXACT version of build-tools requested. In my case, I had a later version installed(33.0.0), but in order to make it work I had to download an older one 30.0.3.
This works for me! be careful with the new java versions because they cause error, check that you have everything installed and in your specific directory,
I did not use openJDK
export JAVA_HOME="/usr/lib/jvm/java-8-jdk" \
&& export PATH=$JAVA_HOME/bin:$PATH \
&& export ANDROID_HOME=$HOME/Android/Sdk \
&& export PATH=${PATH}:${ANDROID_HOME}/tools \
&& export PATH=${PATH}:${ANDROID_HOME}/platform-tools \
&& export GRADLE_HOME=/usr/share/java/gradle/bin/gradle \
export PATH=$PATH:$GRADLE_HOME/bin
Linux 4.14.39-1-MANJARO #1 SMP PREEMPT Wed May 2 19:03:39 UTC 2018 x86_64 GNU/Linux
I added <preference name="android-minSdkVersion" value="19" />
to my conf.xml and the build was successful.
The solution for this question is here
https://docops.ca.com/devtest-solutions/8-0-2/en/installing/setting-up-the-mobile-testing-environment/preinstallation-steps-for-mobile-testing/
Please follow this steps, and solve your problem.
The Android SDK package contains a component called compile tools. The mobile test requires at least version 19.0.1, 19.1.0 or 20.0.0.
If these versions are not installed with your ADT package, you may receive an error message when creating a mobile asset in the DevTest Workstation:
Mac IOS
Edit ~/.bash_profile by using vi or other shell editor
vi ~/.bash_profile
Add the following lines:
export ANDROID_HOME=~/Library/Android/sdk
export PATH=${PATH}:~/Software/android-sdk-macosx/tools:~/Software/android-sdk-macosx/platform-tools"
(save the file, and exit)
load those updated env variables to the current shell env:
. ~/.bash_profile
If from some reason you have an old version of the build tools, you can update them from the android development studio:
Configure --> SDK Manager --> select "Android SDK Build-Tools
Check the "Show Package details"
review the versions of this package, update if needed
Well Many people give their answer, some answer is same, some answer id different. I try many answer but they are did not work for me, of course I try from above answer also but did not solve my issue. And I don't know why but I have the same error even my issue solved by this ANSWER. I just want to write it might be helpful for someone.
I have tried all the above solution. None works.
Until I was linked to https://forum.ionicframework.com/t/ionic-v4-no-installed-build-tools-found/152150.
Apparently, you must run the command as root. Sudo is not enough. You need to change to root user before you can run all the commands.
Open Command Prompt Check for ANDROID_HOME path using SET ANDROID_HOME, if not set then set using below command.
SET ANDROID_HOME="C:\Users\VenkateshMogili\AppData\Local\Android\Sdk"
OR
open system environment variables and create new variable as
Variable Name: ANDROID_HOME
Variable Value: C:\Users\VenkateshMogili\AppData\Local\Android\Sdk
and open cordova.gradle file (/platforms/android/CordovaLib/cordova.gradle) and search for getAndroidSdkDir() method and Replace the ANDROID_HOME path ("C:/Users/VenkateshMogili/AppData/Local/Android/Sdk") instead of System.getenv("ANDROID_HOME")
If license problem arises then type below command by opening the command prompt in C:\Users\VenkateshMogili\AppData\Local\Android\Sdk\tools\bin
sdkmanager "build-tools;27.0.3" //<-that will create build-tools folder and licenses folder.
It works for me.
Warning for developers using Virtual Machines
I spent a very long time trying to resolve this issue. I tried everything in this post and many more solutions on the web. However, after many failures and going through what everyone on the web was saying I still couldn't resolve the issue on my VM - which is a Windows 10 image on VMWare Workstation.
After reviewing all the solutions and descriptions of machines/operating systems people were developing on the glaring difference in my setup was I was developing in a VM.
Solution: I pulled all my code onto the host machine (Windows 10 OS), reinstalled all the dependencies, and sure as heck it all worked out first go around. After a lot of research I found some warnings that Android Studio has some known issues around installing properly in some VMs. So if you were like me & tried all solutions (many times over) and nothing worked, but you're in a VM, you may need to consider building on your host (or other physical machine)
This issue also occur if you do an upgrade to you cordova installation.
Check if your log error has something like:
Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=undefined (recommended setting) <-------------
ANDROID_HOME=/{path}/android-sdk-linux (DEPRECATED)
Using Android SDK: /usr/lib/android-sdk
Starting a Gradle Daemon (subsequent builds will be faster)
In such case, just change ANDROID_HOME to ANDROID_SDK_ROOT in your ~/.bashrc
or similar config file.
Where before was:
export ANDROID_HOME="/{path}/android-sdk-linux"
Now is:
export ANDROID_SDK_ROOT="/{path}/android-sdk-linux"
Don't forget source it: $ . ~/.bashrc after edition.
Check whether you have added android SDK paths to the environment file (.bash_profile). If you installed android studio with default path, then add the below lines to your environment file. In my case, I am using bash so I have updated the .bash_profile
export ANDROID_HOME=~/Library/Android/sdk
export ANDROID_SDK_ROOT=~/Library/Android/sdk
export ANDROID_AVD_HOME=~/.android/avd
I wasted a day to resolve this issue and finally I got solution
-First I removed ionic cordova platform android
-Install ionic cordova platform android#8
That's it
create a ~/.bash_profile and ~/.zshrc file.
touch ~/.bash_profile;
touch ~/.zshrc;
edit and copy/paste this in your ~/.bash_profile or ~/.zshrc file
So, go to your file manager and show all hidden files by using Cmd+Shift+. or Cmd+>
i) Edit your .zshrc file
export LANG=en_US.UTF-8
export ANDROID_HOME=/Users/bookwarm/Library/Android/sdk
export ANDROID_SDK_ROOT=~/Library/Android/sdk
export ANDROID_AVD_HOME=~/.android/avd
export PATH=$PATH:/Users/{your name}/Library/Android/sdk/tools
export PATH=$PATH:/Users/{your name}/Library/Android/sdk/tools/sdkmanager
export PATH=$PATH:/Users/{your name}/Library/Android/sdk/platform-tools
export PATH=$PATH:/Users/{your name}/Library/Android/sdk/build-tools
export PATH=$PATH:/Users/{your name}/Library/Android/sdk/tools/bin
export ANDROID_NDK=/Users/{your name}/Library/Android/sdk/ndk-bundle
export JAVA_HOME=$(/usr/libexec/java_home)
ii) Edit your .bash_profile file
export ANDROID_HOME=/Users/{your name}/Library/Android/sdk
export ANDROID_SDK_ROOT=~/Library/Android/sdk
export ANDROID_AVD_HOME=~/.android/avd
export PATH=$PATH:/Users/{your name}/Library/Android/sdk/tools
export PATH=$PATH:/Users/{your name}/Library/Android/sdk/tools/sdkmanager
export PATH=$PATH:/Users/{your name}/Library/Android/sdk/platform-tools
export PATH=$PATH:/Users/{your name}/Library/Android/sdk/build-tools
export PATH=$PATH:/Users/{your name}/Library/Android/sdk/tools/bin
export ANDROID_NDK=/Users/{your name}/Library/Android/sdk/ndk-bundle
export JAVA_HOME=$(/usr/libexec/java_home)
Save your file with file->save like you would save any regular file, after that write this in your terminal
source ~/.bash_profile;
source ~/.zshrc;
Close you terminal and run your command now
I have been trying to get my head around using uiautomator and I understand creating the test cases. I tried the first two steps of building the JAR according the the Android developer guide for UI Testing (http://developer.android.com/tools/testing/testing_ui.html) and that worked fine, but I am unsure on how to follow the next steps and building the JAR file with ant. Please can anyone help me with this issue.
Here are the steps that I have done so far:
<android-sdk>/tools/android create uitest-project -n <name> -t 1 -p <path>
set ANDROID_HOME=<path_to_your_sdk>
This is the step that I am stuck on:
ant build
The error I get when I use the command prompt is:
'ant' is not recognized as an internal or external command, operable program or batch file.
In the terminal run
which ant
It seems you do not have ant installed. If no location like /usr/bin/ant shows up after you run the command above, use this to install it:
sudo apt-get install ant
Try again after. It should work.
If you're using ADT, I recommend downloading Apache ant and placing it within the sdk/tools/ant folder. Then change your PATH variable to direct to the ant bin folder.
you have this error because you wrote "ant build" from incorrect path.
I did (this command generate build.xml, local.properties, project.properties files):
<android-sdk>/tools/android create uitest-project -n <name> -t 1 -p <path>
I changed in build.xml first line like:
<project name="name" default="build">
after that I run ant from eclipse. Build was success.
Have you installed ant? If not then do it from this site: http://ant.apache.org/manual/install.html
If yes then follow these steps:
Navigate to your project directory and means (go to bin of your project)
Using command window execute the function: ant build
Ensure that your default JAVA_HOME points to JDK installation, not the JRE, and check if your compiler is in the PATH. Try to type “javac” in the command prompt. If javac is not found, then you should put your bin directory in the PATH.
For example, in Windows:
SET PATH=c:/jdk1.5.0_07/bin;%PATH%
This site might help further: http://looksok.wordpress.com/2014/02/08/uiautomator-in-eclipse/
If you have ADT with Eclipse then you can find ant in the plugins directory of Eclipse.
I'm trying to get the new GCM service to work for me, so I've been following the demo as described here: http://developer.android.com/guide/google/gcm/demo.html
So far, everything works well. However, I'm supposed to build the ant files using the command line now, and that's where things stop working.
For some reason, this command $ android update project --name GCMDemo -p . --target android-16 gives me a very nice
'android' is not recognized as an internal or external command,
operable program or batch file.
Normally this can be fixed easily with a quick Google search, but I haven't found a single other user with this problem. Could someone tell me what the problem is?
My educated guess is that I need to add the Android tools folder to my PATH, but I'd rather be sure first.
Your guess is correct, just add the folder containing android.bat(tools folder) to the PATH. Otherwise the system will not be able to find the program.
Other possibility is change directory (using cd) to the tools folder, and execute the command from there. Since the current directory (whatever it is) is usually in the PATH, the system will find it. But this is not handy, because you frequently want to execute this command being in a different directory.
Find android.bat on your system. On mine (win 8 x64) it's under C:\Users\{username}\AppData\Local\Android\sdk\tools\android.bat
Open a command console, and use the 'doskey' command:
doskey android=C:\Users\{username}\AppData\Local\Android\sdk\tools\android.bat $*
This will continue to work in the open command console. To make it permanent is more difficult: http://darkforge.blogspot.com/2010/08/permanent-windows-command-line-aliases.html
You can also try adding it to your PATH as another poster suggested, but that didn't work for me. I recommend an easy gui for doing it, such as https://patheditor2.codeplex.com/
In Windows 7, navigate to
Control Panel\System and Security\System > advance system settings > environment variables
and update the path to include the following:
<android-root>\android-sdk-windows\tools
Use semicolons to separate paths if more than one exist.
On Windows 10, add both:
C:\Users\Parag Jain\AppData\Local\Android\sdk\tools
C:\Users\Parag Jain\AppData\Local\Android\sdk\build-tools
to the PATH environment variable of System and User. Make sure that you close your command prompt and restart a new prompt and then try the command.
Compiling previous answers I did the following to get Android SDK and gradle working (You need gradle working anyway to compile your Android project):
Prerequisites. You have Java jdk, Android SDK and gradle installed in the folders like I found on my computer. Please, check it:
C:\Program Files\Java\jdk1.X.X_XX\
C:\Users{username}\AppData\Local\Android\sdk\
C:\Program Files\Android\Android Studio\gradle\gradle-X.X\
Set up three new system variable (Control Panel\System and Security\System Advance system ->settings->environment variables-system variables). Do not forget to change java and gradle versions.
JAVA_HOME C:\Program Files\Java\jdk1.X.X_XX
ANDROID_HOME C:\Users\{username}\AppData\Local\Android\sdk
GRADLE_HOME C:\Program Files\Android\Android Studio\gradle\gradle-X.X\
Add the following paths to system paths (Control Panel\System and Security\System Advance system ->settings->environment variables-system variables):
%JAVA_HOME%
%ANDROID_HOME%\tools\
%ANDROID_HOME%\platform-tools
%GRADLE_HOME%\bin
Close and open once again your Dos application (Cmd terminal, etc.). You might want to REBOOT your computer, to make sure, that the system sees the variables. If you do not want to reboot, you can use the advice of #wordsforthewise
doskey android=C:\Users\{username}\AppData\Local\Android\sdk\tools\android.bat $*
Check if Android SDK and gradle work properly with the terminal commands
$ java -version
$ android list target
$ gradle -v
What worked for me:
Setting up the ANDROID_HOME variable as a System variable instead of a user variable.
I am using Windows 10, not sure if that matters.
I resolved this issue permanently using the below steps.
OS version : windows 7 64 bit
Solution : Set environment variable for android sdk and gradle
Step 1: Create new "ANDROID_HOME" User Variable
Variable Name: ANDROID_HOME
Variable Value C:\Users{user_name}\AppData\Local\Android\sdk\
Step 2: Create new "GRADLE_HOME" User Variable
Variable Name: GRADLE_HOME
Variable Value C:\Program Files\Android\Android Studio\gradle\gradle-x.x\
*Do not forget to change and gradle versions.
Step 3: Create "ANDROID_HOME" System Variable
Variable Name: ANDROID_HOME
Variable Value C:\Users{user_name}\AppData\Local\Android\sdk\
Step 4: Create new "GRADLE_HOME" System Variable
Variable Name: GRADLE_HOME
Variable Value C:\Program Files\Android\Android Studio\gradle\gradle-x.x\
*Do not forget to change and gradle versions.
Reopen the command prompt and confirm below command output :
1. gradle -v
2. android list target