How to download Android sdk and set android_home path on Windows? - android

When I download from http://developer.android.com/sdk/index.html, I am getting the .exe file, and I'm having trouble setting the path. How to set the path ANDROID_HOME on Windows? When I build the ionic app I'm getting the below error
[Error: Android SDK not found. Make sure that it is installed.
If it is not at the default location, set the ANDROID_HOME environment variable.]
ERROR building one of the platforms: Error: cmd: Command failed with exit code 2
You may not have the required environment or OS to build this project
Error: cmd: Command failed with exit code 2

For windows:
Right click on My computer -> properties -> Advanced system setting -> Environment Variables
Now Edit Path on system variables and append at the end of the line:
;C:\yourSdkDirectoryLocation\tools;C:\yourSdkDirectoryLocation/platform-tools
Error: ANDROID_HOME is not set and "android" command not in your PATH on OS X

I'm not exactly sure about your error, but if you're trying to change a value in PATH variable (Windows) here and I would appreciate some more information about your issues.

Related

ANDROID_HOME environment variable not saving

I am trying to begin development of an android app using meteor however I am running into this error:
"Failed to find 'ANDROID_HOME' environment variable"
This seems to be a common problem and has received mixed attention as in these other 3 questions.
Error: Failed to find 'ANDROID_HOME' environment variable
ERROR: Error: Failed to find 'ANDROID_HOME' environment variable
Android Error: Failed to find 'ANDROID_HOME' environment variable
But doesn't seem to have an answer in any of them. In my case it seems that the variable is not saving after restarting the shell.
Following the instruction from these two links:
https://www.meteor.com/tutorials/blaze/running-on-mobile
https://guide.meteor.com/mobile.html#installing-prerequisites
I am stuck on the "meteor run android" command. In the terminal it returns:
Status of the individual requirements:
✓ Java JDK
✗ Android SDK: 'ANDROID_HOME' environment variable is set to non-existent path:
/home/eru/Library/Android/sdk
Try update it manually to point to valid SDK directory.
✗ Android target: Android SDK not found. Make sure that it is installed. If it
is not at the default location, set the ANDROID_HOME environment variable.
✗ Gradle: Could not find gradle wrapper within Android SDK. Might need to
update your Android SDK.
Looked here: /home/eru/Library/Android/sdk/tools/templates/gradle/wrapper
When I run:
echo $ANDROID_HOME
I get nothing. and when I run:
echo $PATH
I get a bunch of stuff that does include:
$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
So I checked the "env" command and ANDROID_HOME wasn't present but $PATH does have what is required for the SDK.
I ran the export commands again, copied and pasted from the instructions. "echo $ANDROID_HOME" now returns the correct directory and is present when I run "env".
Interestingly "source ~/.bash_profile" doesn't exist so to restart the shell I just closed all my terminals and tried "echo" again. ANDROID_HOME is once again non-existent.
Why was my $PATH env variable saved but not $ANDROID_HOME?

While installing IONIC, ANDROID_HOME variable is set but getting 'Failed to find 'ANDROID_HOME' environment variable'

As the title states, I've set up the variable in my .bashrc like so
export ANDROID_HOME=$HOME/Android/Sdk
PATH=$PATH:$HOME/Android/Sdk:$HOME/Android/Sdk/tools
export PATH
and shows fine when I do:
printenv ANDROID_HOME
/home/chris/Android/Sdk
printenv PATH also shows the right paths.
I can cd into that directory and go into the tools directory and run ./android and it works fine (it's there).
However, doing:
ionic build android
(in a separate directory, same shell) I get:
Error: Failed to find 'ANDROID_HOME' environment variable. Try setting setting it manually.
Failed to find 'android' command in your 'PATH'. Try update your 'PATH' to include path to valid SDK directory.
I have re-installed IONIC and re-installed the Android SDK as well.. Any ideas?
Ubuntu 16.10 64bit
Thanks.
Ok I figured it out, I was trying to
sudo ionic build android
instead of just
ionic build android
..and sudo has a different set of env variables. Learn something new everyday!
I started to use sudo because I was getting some permission denied errors, but it should've all been cleared, instead of resorting to super user!

sudo ionic run android not working

I am trying to run a hybrid app on my android phone using ionic using the following command:
sudo ionic run android
However I keep receiving this error :
Error: Failed to find 'ANDROID_HOME' environment variable. Try setting
setting it manually. Failed to find 'android' command in your 'PATH'.
Try update your 'PATH' to include path to valid SDK directory.
I have already added platform tools & tools to PATH updated ANDROID_HOME to point to my sdk root.
The ANDROID_HOME environment variable shows up when I run env and the PATH has the tools and platform tools too. Additionally I can execute android too. It launches the SDK Manager as expected.
Details:
ANDROID_HOME: /home/user/Android/Sdk
$PATH: /home/user/Android/Sdk/tools:/home/user/Android/Sdk/platform-tools
Please help! This is driving me up the wall!
Credit for this goes to #heemayl on AskUbuntu.
https://askubuntu.com/a/783805/247116
sudo sanitizes the environment and by default only keeps certain
environment variables available with modifying the values of some
(e.g. PATH).
You can pass the variable ANDROID_HOME manually:
sudo ANDROID_HOME="/actual/path" ionic run android
Or preserve the current environment:
sudo -E ionic run android

ERROR: Error: Failed to find 'ANDROID_HOME' environment variable

Solution:
Remove platform with ionic platform rm android
change permission chmod 777 /path/to/update-notifier-cordova.json
add platform with ionic platform add android
It's probably due to another project I created that would cause the permission change. I think chaning the permission (see step #2) should be enough.
Original post:
When running ionic run android I got this error message:
ERROR: Error: Failed to find 'ANDROID_HOME' environment variable. Try
setting setting it manually. Failed to find 'android' command in your
'PATH'. Try update your 'PATH' to include path to valid SDK directory.
I set the environment variable in the bashrc file:
export ANDROID_HOME=/home/think/dev/android-sdk-linux
export PATH=$PATH:/home/think/dev/android-sdk-linux/tools
It used to work a few hours before and I can't remember to change anything in the settings or whatever. :/
I installed npm, cordova, inonic again, but I still got this error.
I'm using ubuntu 14.04
~/.profile is ignored if if there's ~/.bash_profile or ~/.bash_login in your home, as a result of ~/.profile being ignored, ~/.bashrc isn't sourced.
Check for either ~/.bash_profile or ~/.bash_login present in your home, and take a new terminal, will help you.

Error while building android platform at cmd

Error at cmd when building ionic project with android
[Error: Failed to find 'ANDROID_HOME' environment variable. Try setting setting it manually.
Failed to find 'android' command in your 'PATH'. Try update your 'PATH' to include path to valid SDK directory.]
ERROR building one of the platforms: Error: cmd: Command failed with exit code 2
You may not have the required environment or OS to build this project
Error: cmd: Command failed with exit code 2
at ChildProcess.whenDone (C:\Users\Hasan\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\cordova\superspawn.js:139:23)
at ChildProcess.emit (events.js:110:17)
at maybeClose (child_process.js:1015:16)
at Process.ChildProcess.handle.onexit (childprocess.js:1087:5)
so what is the problem what must I do to fix it ?? I have android sdk on my pc, and m working on windows 10, I have installed nodejs. Can anybody help me
Go to Advanced System Settings, then go to Environment Variables and select PATH variable to edit. There you have to append path to platform tools and tools of sdk, for example like this ;C:\Development\android-sdk\platform-tools;C:\Development\android-sdk\tools
Now go to cmd and run android, if that does not open android sdk manager, then it means path has not been set correctly or cmd is not recognizing enviroment variable updtes, in that case restart your computer and it will work.
Go to Advanced System Settings, then go to Environment Variables
Then add new Variables with name "ANDROID_HOME" and the value will be you SDK path like
C:\Android\sdk
Make sure to restart visual studio before run again
it will fix

Categories

Resources