ANDROID_HOME environment variable not saving - android

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?

Related

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

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

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.

ANDROID_HOME environment variable issues with Appium

I am trying to run Appium on the command line with OSX El Capitan to test an Android application. I have been able to use Appium many times with the GUI version but have not had the same luck in the terminal. The issues I am facing stem from setting the $ANDROID_HOME environment variable. I have read other posts regarding this problem but the solutions have not helped me.
I have the following in my bash_profile :
export ANDROID_HOME=/Users/adamjakiela/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
I then run source ~/.bash_profile and am able to start the SDK by running the android command. I can also print the environment variable:
echo $ANDROID_HOME
/Users/adamjakiela/Library/Android/sdk
But then, when I run Appium on the command line I receive the following message which eventually leads to other problems:
warn: The ANDROID_HOME environment variable is not set to the Android SDK root directory path.
I can also run the Appium doctor and see the following:
Running Android Checks
✖ ANDROID_HOME is not set
Appium-Doctor detected problems. Please fix and rerun Appium-Doctor.
Additionally, I have installed all the build tools for the applicable versions of Android and have had no problem build my applications or using the Appium GUI version by pointing it to the $ANDROID_HOME location.
Why are the errors shown by Appium inconsistant with the fact that the $ANDROID_HOME environment variable is set and that other applications are able to use the Android SDK?

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.

Categories

Resources