英文:
"zsh: command not found: adb" after adding ANDROID_HOME and PATH variables to .zshrc
问题
我正在尝试使用 npm expo start
在 Expo Go 中运行 React Native 应用程序。
我已经安装了 Android Studio 并找到了我的 Android SDK 文件夹,位于 C:\Users\username\AppData\Local\Android\Sdk
,然后将此路径添加到 .zshrc
中的 ANDROID_HOME 和 PATH 变量,如下所示:
export ANDROID_HOME=$HOME/../../mnt/c/Users/username/AppData/Local/Android/Sdk
export PATH=$ANDROID_HOME/platform-tools:$PATH
export PATH=$ANDROID_HOME/tools:$PATH
export PATH=$ANDROID_HOME/tools/bin:$PATH
重新加载后,我尝试在终端中运行 adb
并得到以下错误:
zsh: command not found: adb
然而,我可以直接运行 adb,命令如下:$HOME/../../mnt/c/Users/username/AppData/Local/Android/Sdk/platform-tools/adb.exe
(我必须明确添加 .exe,否则它不会运行)。
我怀疑我可能在 .zshrc
中添加了不正确的路径,将它们添加到了错误的文件中,或者 SDK 文件夹放错了位置。
我已经查看了几个类似的问题,尽管许多人的 SDK 文件夹位于不同位置(例如 /Users/username/Library/Android/sdk
),但它们都建议添加相同的 PATH 变量。
我对 Android Studio 和添加 PATH 变量还很陌生,因此非常感谢任何建议。
英文:
I'm trying to run a React Native app through Expo Go using npm expo start
.
I've installed Android Studio and located my Android SDK folder in C:\Users\username\AppData\Local\Android\Sdk
, then added this path to the ANDROID_HOME and PATH variables in .zshrc
as follows:
export ANDROID_HOME=$HOME/../../mnt/c/Users/username/AppData/Local/Android/Sdk
export PATH=$ANDROID_HOME/platform-tools:$PATH
export PATH=$ANDROID_HOME/tools:$PATH
export PATH=$ANDROID_HOME/tools/bin:$PATH
After reloading with source ~/.zshrc
I try to run adb
in the terminal and get:
zsh: command not found: adb
However, I can run adb directly with $HOME/../../mnt/c/Users/username/AppData/Local/Android/Sdk/platform-tools/adb.exe
(I have to add the .exe explicitly or else it won't run).
I suspect that I may have added the incorrect paths in .zshrc
, added them to the wrong file, or that the SDK folder is in the wrong place.
I've looked over several similar issues, which all recommend adding the same PATH variables despite many people having their SDK folders located differently (in /Users/username/Library/Android/sdk
, for example).
I'm still very new to Android Studio and adding PATH variables, so any advice would be greatly appreciated.
答案1
得分: 0
创建符号链接:
cd platform-tools
ln -s adb.exe adb
创建别名。添加到 .zshrc
文件:
alias adb="adb.exe"
定义一个 shell 函数。添加到 .zshrc
文件:
adb() {
adb.exe $@
}
英文:
To run adb.exe
in shell as adb
you have the following options (pick one of them):
- Create a symlink:
cd platform-tools
ln -s adb.exe adb
- Create an alias. Put to
.zshrc
:
alias adb="adb.exe"
- Define a shell function. Put to
.zshrc
:
adb() {
adb.exe $@
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论