I don't understand the difference between the path variables which you set in Android Studio Preferences which can be seen below and ones set in zshrc/bashrc.
I add this path in but when trying an ADB command, it is not recognized.
However, since i'm using zsh shell, same thing applies for bash. I add/export the PATH variable like i'm sure most people are familiar with.
As seen in last line, this is same path that was added to the AndroidStudio preferences, however now as you can see below. ADB is found!
What exactly is the
Android Studio -> Preferences -> Appearance&Behavior -> Path Variables?
Since it has KOTLIN_BUNDLED and im able to run kotlinc command in shell, it would make sense one could add ADB here but apparently not.
What is difference between these Path Variables and the Path Variables added to zshrc or bashrc?
PS: mirror is just an alias for an adb command
Related
when typing "adb devices" in Powershell, it return a prompt to ask "How do you want to open this file".
However, if I use "adb.exe devices", it works and give me the list of devices.
As I have a lot of scripts written as adb instead of adb.exe, is there a way to fix this?
In cmd, typing adb devices would also work. But the scripts were all PS based. So fixing this in powershell will really helps. Thanks.
As you've confirmed, the problem was an extraneous, empty file literally named adb (without a filename extension) that resided in your C:\WINDOWS\system32 directory.
Since the PATH environment variable (typically) lists C:\WINDOWS\system32 before the directory in which the desired target executable (adb.exe) is located, C:\Program Files (x86)\Intel\Platform\..., PowerShell attempted to execute C:\WINDOWS\system32\adb, which - as an extension-less file - triggered the GUI dialog you saw.
Removing the extraneous C:\WINDOWS\system32\adb file solved your problem.
Get-Command -All adb helped discovered the problem: it listed all forms of a command named adb known to PowerShell, in order of precedence, with information about their type and location; that is, the effective command - the one that is actually invoked - was listed first.
Read on for background information.
As all shells do, if a command uses a mere (file) name (as opposed to a file path), PowerShell looks for executables in the directories listed in the PATH environment variable (accessible as $env:PATH in PowerShell), in order.
That is, if you submit a command line with command name adb, PowerShell - after looking for an internal command by that name first (an alias, function, or cmdlet) - looks for an executable file whose base name is adb, in the directories listed in $env:PATH, and invokes the first one it finds.
On Windows, an executable file is one whose filename extension is listed in the PATHEXT environment variable ($env:PATHEXT); again, the extensions listed there are considered in order. By contrast, on Unix-like platforms it is solely the file mode (the permission bits) that determine whether a file is executable.
However, unlike other shells, PowerShell doesn't just look for executable files in $env:PATH, it considers any file that exactly matches the command name given executable, and in effect passes such a file to the Invoke-Item cmdlet, which triggers the default GUI shell action on the file, equivalent to double-clicking a document in File Explorer on Windows.
This problematic behavior is discussed in this GitHub issue, which proposes that only true executables be considered commands.
I'm having precisely the same issue as this person:
android' is not recognized as an internal or external command
However, I have also set the PATH environment variable (Windows 7) as recommended in the answer to the above post. In particular, I have:
C:\Users\p\AppData\Local\Android\android-sdk\tools
and
C:\Users\p\AppData\Local\Android\android-sdk\platform-tools
In addition, I have set %ANT_HOME%\bin and %JAVA_HOME%\bin. I have checked that the android.bat is indeed in the tools directory pointed to, that the PATHEXT variable contains ".bat", and I have restarted the command prompt. And yet 'android' is not recognized.
Does anyone have an idea what might be the problem? Many thanks in advance!
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 command console you executed the doskey command in. To make it permanent is more difficult: http://darkforge.blogspot.com/2010/08/permanent-windows-command-line-aliases.html
I do not know what causes the issue with the path variable.
However, the workaround I've used is to move to the "tools" directory and call android from there; I've added "--path " to point to the directory in which the project resides.
Details on how to manage android projects from the command line can be found here:
http://developer.android.com/tools/projects/projects-cmdline.html
You might have installed Cygwin as part of the SDK. I had the same problem "android.bat is not recognized as an internal or external command". So, Uninstall the Cygwin and try again (you might not able to uninstall Cygwin, since a mysterious “permission denied” when deleting the Cygwin files by default). You need to own access to this mysterious Cygwin files by taking ownership:
takeown /r /d y /f cygwin (do this, wherever is your cygwin folder is)
This command takes ownership recursive of the folder, without asking anything and gives Full Access to Everyone recursively in the folder:
icacls cygwin /t /grant Everyone:F
And finally, the command which deletes it all and removes Cygwin:
rmdir /s /q cygwin
Good bye Cygwin! ;-)
Now try again. (This worked for me)
PS: You can always re-install cygwin again. So, nothing wrong giving it a try. Good Luck
**Set the path in windows**
Control Panel\System and Security\System > advance system settings > environment variables
and update the path to include the following:enter code here
<android-root>\android-sdk-windows\tools
Use semicolons to separate paths in case yo have to add more path .
When I try to compile my Android NDK program, it shows the following error:
Program "${SA}\android-ndk-r8\ndk-build.cmd" not found in PATH
(the value of the environment variable "SA" is C:)
I am using Cygwin on Windows 7. How do I open my .bashrc file? I read that I need to add the following lines to my .bashrc to fix the problem:
NDK_HOME=/opt/android-ndk-r8
export NDK_HOME
But I am not sure how to open .bashrc and edit the file as I have never done this before.
There are a number of text editors available under Cygwin, either installed by default or installable by using setup.exe.
vi/vim is probably the most common. It has a bit of a learning curve. Run vimtutor from your command line for a tutorial.
If you're very ambitious, you can try emacs. Run emacs from the command prompt, then Control-H t to run the built-in tutorial.
nano is a simpler and more user-friendly editor. It shows the most common commands at the bottom of the screen, including a help command. It may be the best one to start with.
You can use Windows editors like Notepad or Wordpad, but they're likely to add Windows-style end-of-line markers to any files you edit. You can use the dos2unix command (man dos2unix for more information) to fix that up, but IMHO that's more trouble than it's worth unless you really like Windows editors more than Unix-style editors.
The echo command in Henry's answer is a quick-and-dirty way to add a single line to a file. If you want to do anything more complex (say, deleting or changing lines, or adding lines other than at the very end), you'll need a real editor. To edit your .bashrc:
nano ~/.bashrc
(or use another editor of your choice).
You can do
echo "NDK_HOME=/opt/android-ndk-r8 export NDK_HOME" >> ~/.bashrc
be sure to restart your cygwin window afterwards
I am trying to familiarise myself with using adb from the command prompt.
My adb.exe is installed at:
C:\Program Files(x86)\Android\android-sdk\platform-tools
I have tried starting off by typing in cd:C\ to take me to the C drive
Then I have typed in the path quoted above, sometimes putting Program Files(x86) in quote marks,
other times inserting % in between Program and Files.
But always I get the same answer - "The system cannot find the path specified".
Even when I type the path and then put in “adb devices” I get nothing.
I have tried inserting each of the following in the path in system variables as follows:
;C:\"Program Files(x86)"\Android\android-sdk\platform-tools\
C:\"Program Files(x86)"\Android\android-sdk\platform-tools\
;C:\Program Files(x86)\Android\android-sdk\platform-tools
And then typing “adb devices”.
The message is the same – “adb is not recognised as an internal or external command, operable program or batch command.
You can call adb directly from the directory you are currently in: "C:\Program Files(x86)\Android\android-sdk\platform-tools\adb.exe" (With quotes!) You can also navigate to the platform-tools directory and then call adb.exe, use cd .. to go to a directory level up, you can hit TAB to let windows list the appropriate directories, this works also if one or more characters are entered.
Btw, just added "C:\Program Files\Android\android-sdk\platform-tools" to my PATH and it works just fine! Separate the entires with a semicolon.
for using a 64 bit os try going step by step,
type in command prompt
cd "C:\Program Files (x86)"
you will enter C:\Program Files (x86)directory
then type
cd Android\android-sdk\platform-tools
It's the spaces that are messing people up. Windows users need to remember one important thing when dealing with command lines: do not install the utilities to folders where there's a space in the folder name - it will save you a lot of hassle which sometimes can't even be solved by using quotes.
For example, I've installed the Android SDK to C:\Android\android-sdk-windows
To open a command prompt, I have a shortcut to ("target") C:\Windows\System32\cmd.exe
And the "Start in" path is C:\Android\android-sdk-windows\platform-tools
now all I do is double-click the shortcut and I can dive right in to ADB
I have to use NDK for a clien't project. I am using Windows 7.
I followed the installation instructions. I have installed Cygwin 1.7.1.
In Cygwin bash, I go into the android NDK root directory.
When I see the contents of the directory, usin $dir command, I can see all the contents including ndk-build, but when I try to use ndk-build, this is the result I get:
$ndk-build
bash: ndk-build: command not found.
Not sure what I am doing wrong.
Cygwin emulates a GNU/Linux environment on your Windows computer. This means you're working with a "Shell" which is not exactly the same as the Windows command-line.
If you type asdf.exe in your Windows command-line, it tries to find asdf.exe in the current directory. If it can find it, the file is executed. If it can't find it, it'll go through every directory of your %PATH% and try again.
However, if you type asdf in your bash (there are multiple kind of shells, the Bourne Again SHell is one of them), it will not look after it in the current directory. Instead it'll try to find it in one of your PATH directories. Can't give you any sources here, but AFAIK it's for security reasons. If you want to run a file which is not in your PATH, you must prepend it with its absolute of relative path. You can use ./, it points to the current directory.
That's why you need to type ./ndk-build, because it's in the current directory and not your path. Something like /path/to/ndk/ndk-build will also work, but you have to type a bit more :).
(In fact it's even more complicated, if you want to execute a file, you need execute permissions for it. Google will help you if you have any problems with that.)