zsh: command not found: adb problem analysis

Problem Description

When using adb to debug an Android device on a Mac , an error message zsh: command not found: adbappears .
insert image description here
The above error means that adb cannot be used in the shell that blocks the gun, and the current shell is zsh .

Introduction to zsh

zsh is also a shell, and the default shell of Unix derivative systems is bash . Starting with the release of macOS Catalina (macOS 10), zsh is used as the default shell on the Mac as the default login shell and interactive shell.
Execute the following command to view the shell terminals available in the current system:
cat etc/shells
insert image description here
Execute echo $SHELLthe command to view the shell version used by the current terminal, and the window title also prompts the shell version.
insert image description here
Execute cat etc/passwd | grep shthe command to view the default shell version of the current system.
insert image description here

solution

Two options are given below:

Solution 1: Modify zsh to bash

  1. Execute the following command to change the default shell to bash :
    chsh -s /bin/bash
  2. Then call the following command to immediately apply the bash configuration file:
    source ~/.bash_profile
  3. Executing adb shellthe test can use the adb command normally.

Solution 1: Configure zsh terminal

  1. Execute touch ~/.zshrcthe command to check whether there is a .zshrc file, and if not, the file will be created automatically.
  2. Then execute open ~/.zshrcthe command to open the file or use vi to edit it.
  3. Enter source ~/.bash_profilethis .
  4. execute Applies file modifications source ~/.zshrcimmediately .
  5. After executing the test, the adbadb shell command can be used normally .

Regardless of the solution, you need to configure the Android environment in the .bash_profile file to use adb , and configure the path of the Android Sdk :

export ANDROID_HOME=/Users/vin/Library/Android/sdk
export PATH=${PATH}: ${ANDROID_HOME}/tools
export PATH=${PATH}: ${ANDROID_HOME}/platform-tools

The Mac shortcut key "shift + command + ." displays system hidden files (directories) such as ***.bash_profile*** and Library .

Guess you like

Origin blog.csdn.net/CJohn1994/article/details/127937825