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.
Related
I'm new to Hybrid App Development, since a few days I have been fighting with how to build my Ionic App's APK file. I have tried ionic cordova build --release android as suggested here but I see following errors:
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.`
even then my ANDROID_HOME is set. Please note that I have tried reinstalling both Ionic and Android Studio but still getting the same error. I'm using Ubuntu 16.04.
What does happens when you do echo $ANDROID_HOME ? Does it correctly prints out the path to android home ?
If not :
export ANDROID_HOME=/<installation location>/android-sdk-linux
Also consider adding it to your path variable
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
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!
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
I am using Ubuntu 14.04 LTS 64 bit, I have an ionic project and i have already Android installed, but when trying to emulate or run as Android i get these errors
Running command:
/home/fathi/ionic/favorlinks/hooks/after_prepare/010_add_platform_class.js
/home/fathi/ionic/favorlinks add to body class: platform-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.
I have tried to modify ~/.bashrc file by adding this
export ANDROID_HOME=/home/fathi/Android/Sdk
But, i still getting the same errors
You are not including the ANDROID_HOME in PATH. Add the following code snippet in your ~/.bashrc.
export ANDROID_HOME=/home/fathi/Android/Sdk
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
Note: Make sure to source the ~/.bashrc or open a new terminal.
After trying and installing many things, I fixed it by typing this command
sudo visudo
and then adding this line
Defaults env_keep +="ANDROID_HOME"
at the end of the file.
I am trying to build an ionic project. I have set up environment for ionic and android in ubuntu. But don't know why the following error is showing on terminal ...
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 set up android home as followings ...
userPC:/codes/myApp$ export ANDROID_HOME=/opt/android-sdk-linux
userPC:/codes/myApp$ export ANDROID_PLATFORM_TOOLS=/opt/android-sdk-linux/platform_tools
userPC:/codes/myApp$ export ANDROID_TOOLS=/opt/android-sdk-linux/tools
userPC:/codes/myApp$ PATH=$PATH:$ANDROID_HOME:$ANDROID_TOOLS:$ANDROID_PLATFORM_TOOLS
my android-sdk-linux is in /opt/ itself. From terminal I can run android command. So, I think environment variable is not the main issue. While I am trying to build ionic project, it shows Failed to find 'ANDROID_HOME' environment variable. I am using Android SDK Build Tools 22 and ionic latest version.
Can anyone tell me how can I solve this issue? I have searches a lot but everywhere I found to setup android sdk and environment variable path correctly. But I already have set up all these things. Thanks!
I think you are doing everything right except for the bin part.Add ANDROID_HOME environment variable to path and point out the corresponding bin directory as:
1.export ANDROID_HOME=/path/to/android/SDK
2.export PATH=$PATH:$ANDROID_HOME/bin
when you issue studio.sh command on the command line, it looks for the bin directory in the path which contain executables! studio.sh is the one in this case.
For more information,Read this
Hope this was helpful.
After long time on search. To make a final fix for this problem
Follow Theses incrustation and it will fix it Correctly
Delete your current installation of node & npm & ionic & cordova
Install nvm follow this install nvm ubuntu
Install node with nvm follow this install node via nvm
Install ionic and cordova
npm install -g cordova ionic
Never use root to install node ,npm ,ionic or cordova
Set your Android Home
export ANDROID_HOME=/path/to/android/SDK
export PATH=$PATH:$ANDROID_HOME/bin
After that its worked fine for my and ionic can see Android SDK home