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
Related
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.
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.
I am MAC OS X Yosemite I have done all the export tutorial to set the android_home but non of it working for me
Making sure ANDROID_HOME is exported and adding the SDK tool directories to PATH should be more than enough to get you going.
Using the terminal
# First, we make sure we have a newline at the end of the .bash_profile
echo >> /Users/abdi/.bash_profile
# We set the ANDROID_HOME value in the .bash_profile
echo "export ANDROID_HOME=/Users/abdi/adt/sdk" >> /Users/abdi/.bash_profile
# We alter the PATH value a bit as well
echo "export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools" >> /Users/abdi/.bash_profile
# We then tell the terminal to update all the things
. /Users/abdi/.bash_profile
Using a GUI (mostly)
You can also open the .bash_profile file in TextEdit using the open -e /Users/abdi/.bash_profile command. If you get some errors about missing files, try running touch /Users/abdi/.bash_profile and retry the open command. In the file that opens, add the following lines at the end.
export ANDROID_HOME=/Users/abdi/adt/sdk
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
Running . /Users/abdi/.bash_profile as in the terminal version after that should get you fully set up.
First need to set the ANDROID_HOME directory
look into your android-sdk-linux(mac) directory and look for 'android' executable file, generally it will exists under 'tools' directory
so edit your .bashrc from home folder
and add this line down there
export ANDROID_HOME=~/android-sdk-linux
PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
Once done, exit your console and run your command again
You could expect an error saying " Please install Android target "android-19" " if it is not set yet.
you may fix that running "android" command and selecting "Android 4.4.2 API 19" to install.
And afterwards, don't forget to give ample permission to directory where the application resides.
I had the same problem. Luckily it is easily fixable. Just follow the next few steps (Command-line from terminal).
Open the bash_profile file using command line arguments with -
vi ~/.bash_profile
OR
It is possible to open bash_profile in TextEdit and make changes there. Use the following command to do this -
open -a "TextEdit" .bash_profile
Check if ANDROID_HOME has been set in this file. If it has been already set, delete it (probably wrong). Also check if PATH in this file has any reference to tools or platform-tools (of the android sdk). You'd be better off deleting these before you start typing the following commands.
Set ANDROID_HOME correctly using the following command
export ANDROID_HOME=/Users/adarsh/android-sdk-macosx
^this is my command because I installed it in that location. Please replace "adarsh" with your username and "android-sdk-manager" with the name of your android sdk folder that you downloaded. Do not copy-paste this command.
For example, if your username is "John" and you the android sdk folder you downloaded and installed is in "Downloads" and you changed your folder name to "sdk", then your command would be -
export ANDROID_HOME=/Users/John/Downloads/sdk
Set PATH with the following command
export PATH=$ANDROID_HOME/tools:$PATH
Refresh your bash_profile to set all the changes we just made by typing the command
source ~/.bash_profile
You should be good to go now and begin developing with ionic!Hope this helps. Cheers.
One source of this problem comes from sudo. If you're sure you've set $ANDROID_HOME correctly then try the following:
sudo visudo
then add
Defaults env_keep += "ANDROID_HOME"
Make sure the env variable you exported is ANDROID_HOME and not android_home (case sensitive).
After you export, test it by typing
> echo $ANDROID_HOME
The result should point to the dir where you installed the SDK.
Last but not least edit your /etc/paths to add dirs $ANDROID_HOME/platform-tools or /Users/abdi/adt/sdk/platform-tools and $ANDROID_HOME/tools or /Users/abdi/adt/sdk/tools to the list. Save file. You might need to edit this file as admin if need be. Close terminal and then Open new terminal. Then type
> echo $PATH
to check if the path is updated.
And then voila, when you type
> which android
you should see the correct path to the binary returned which in your case is /Users/abdi/adt/sdk/tools/android. you should be all set now.
None of the solutions here solved my problem completely. My Node version was little bit old and ionic was giving a warning to upgrade node. After upgrading Node, I had to delete the project and again create the project, then perform all the steps. Hope this helps somebody.
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
I am trying to develop for android and I want to add the adb to my PATH so that I can launch it really easily. I have added directories before by for some reason adb does not want to be found. This is very frustrating. Has anyone else had this problem before?
I created a file .profile and added the following to it.
export PATH = ${PATH}:/Users/simon/Libs/android-sdk-mac_x86/platform-tools/
export PATH = ${PATH}:/Users/simon/Libs/android-sdk-mac_x86/tools
When I check my environment path I see the following:
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/Libs/android-sdk-mac_x86/tools:/Libs/android-sdk-mac_x86/platform-tools
So I know that it is added to my PATH variable. Now when I try to run adb I get that it is not found.
-bash: ./adb: No such file or directory
This is very very frustrating. Could it be a problem with permissions? Has anyone had this problem with OSX and Android?
Add to PATH for every login
Total control version:
in your terminal, navigate to home directory
cd
create file .bash_profile
touch .bash_profile
open file with TextEdit
open -e .bash_profile
insert line into TextEdit
export
PATH=$PATH:/Users/username/Library/Android/sdk/platform-tools/
save file and reload file
source ~/.bash_profile
check if adb was set into path
adb version
One liner version
Echo your export command and redirect the output to be appended to .bash_profile file and restart terminal. (have not verified this but should work)
echo "export PATH=$PATH:/Users/username/Library/Android/sdk/platform-tools/
sdk/platform-tools/" >> ~/.bash_profile
Alternative: Install adb the easy way
If you don't want to have to worry about your path or updating adb manually, you can use homebrew instead.
brew cask install android-platform-tools
Why are you trying to run "./adb"? That skips the path variable entirely and only looks for "adb" in the current directory. Try running "adb" instead.
Edit: your path looks wrong. You say you get
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/Libs/android-sdk-mac_x86/tools:/Libs/android-sdk-mac_x86/platform-tools
You're missing the /Users/simon part.
Also note that if you have both .profile and .bash_profile files, only the latter gets executed.
On my Macbook Pro, I've added the export lines to ~/.bash_profile, not .profile.
e.g.
export PATH=/Users/me/android-sdk-mac_86/platform-tools:/Users/me/android-sdk-mac_86/tools:$PATH
Just encase anyone finds this SO post when using Android Studio which includes the SDK has part of the App package (on Mac OSX).
So as #davecaunt and #user1281750 noted but insert the following line to .bash_profile
export PATH=/Applications/Android\ Studio.app/sdk/tools:/Applications/Android\ Studio.app/sdk/platform-tools:$PATH
The answer for MAC should be:
Open your bash_profile with the following commands: open ~/.bash_profile
In case base profile file doesn't exist, create a new one with the following command: touch .bash_profile then repeat phase 1.
Add the following line: export PATH=/Users/"YOURUSER"/Library/Android/sdk/platform-tools:$PATH
Restart your bash window and test by typing adb shell
Good luck! :-)
In your terminal, navigate to home directory
cd
create file .bash_profile
touch .bash_profile
open file with TextEdit
open -e .bash_profile
insert line into TextEdit
export PATH=$PATH:/Users/username/Library/Android/sdk/platform-tools/
save file and reload file
source ~/.bash_profile is very important
check if adb was set into path
adb version
It should be fine now.
I use zsh and Android Studio. I use a variable for my Android SDK path and configure in the file ~/.zshrc:
export ANDROID_HOME=/Applications/Android\ Studio.app/sdk
export PATH="$ANDROID_HOME/platform-tools:$ANDROID_HOME/tools:$PATH"
Note: Make sure not to include single or double quotes around the specified path. If you do, it won't work.
Android Studio v1.2 installs the adb tool in this path:
~/Library/Android/sdk/platform-tools/adb
So it goes like this:
Run Terminal
run adb version and expect an error output
touch ~/.bash_profile
open ~/.bash_profile
add the above path before the 'closing' :$PATH
source ~/.bash_profile
run adb version and expect an output
Good luck!
It appears that you're still trying to execute adb with ./adb. That asks the shell to run the program named adb in the current working directory.
Try just adb without ./.
In order to make the terminal always have the file ~/.bashrc and there put the path you wish to use, by adding:
export PATH=$PATH:/XXX
where XXX is the path that you wish to use.
for adb, here's what i use:
export PATH=$PATH:/home/user/Android/android-sdk-linux_x86/platform-tools/
(where "user" is my user name).
2nd solution is explained below. But when i close the terminal the change which i made in path variable gets lost. Thus i prefer the first way!
If you are Catalina user follow this
Make sure to be in the Home directory
cd ~
To persist PATH changes and prevent it to be cleaned up after closing the Terminal app, you need to keep the variables in the zshrc file for Catalina
touch .zshrc
Open it with the TextEditor
open -e .zshrc
Insert the command below to add ADB as PATH variable (replace username with your own)
export PATH=$PATH:/Users/username/Library/Android/sdk/platform-tools/
Save the file and close the TextEditor app. Back to the Terminal app, insert the following to source the file
source .zshrc
And you’re done! Let’s test if it was successful
adb version
You should expect something like
Android Debug Bridge version 1.0.41
Version 31.0.2-7242960
Installed as /Users/username/Library/Android/sdk/platform-tools//adb
I added export PATH=${PATH}:/Users/mishrapranjal/android-sdks/platform-tools/ into both places .bash_profile and .profile to make sure it works. Still it wasn't working and then I looked at sarnold's tip about restarting terminal and it worked like a charm.
It saved my time of adding every time this into the PATH whenever I had to run adb.
Thank you guys.
If anyone can't seem to get there .bash_profile file to take any new Paths AND you have other commands in that file (like alias commands) then try moving the PATH statements to the top of the file.
That is the only thing that worked for me. The reason it worked was because I had some typos in my alias commands and apparently this file throws an error and exits if it runs into a problem. So that is why my PATH statements weren't being run. Moving it to the top just let it run first.
In bash profile
just add -
export PATH=$PATH:/Users/username/Library/Android/sdk/platform-tools/
and then in terminal run -
adb version
All answers are well written and helpful but there is one thing that I want to mention. Before adding path variable to .bash_profile kindly check your default shell.
Because i was seting path variable in .bash_profile file but my default shell was zsh that's why i have to run source ~/.bash_profile each time before using adb command.
So first check your default shell:
echo $SHELL
if the output is /bin/bash then you should set path variable in
.bash_profile
If the output is /bin/zsh then you should set path variable in .zshrc
And here is my path variable:
export ANDROID_SDK_ROOT="/Users/aliasjad/Library/Android/sdk"
export PATH="$ANDROID_SDK_ROOT/platform-tools:$PATH"