Linux Android - 找不到命令
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10969753/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Android - Command not found
提问by Biscuit128
I am trying to run the command in ubuntu
我正在尝试在 ubuntu 中运行命令
android update project --path .
android 更新项目 --path 。
However I am getting a android:command not found error.
但是我得到了一个 android:command not found error.
I assume this is something to do with the path which I learnt on here the other day? I was just wondering, what do variable do I need to add (Android I assume) and what do I need to point it too.
我认为这与我前几天在这里学到的路径有关?我只是想知道,我需要添加什么变量(我假设是 Android)以及我还需要指出什么。
采纳答案by Festus Tamakloe
On MacOS/Linux, define the path to wherever you installed your SDK as ANDROID_HOME
:
在 MacOS/Linux 上,将 SDK 安装位置的路径定义为ANDROID_HOME
:
MacOS
苹果系统
$ export ANDROID_HOME=/Applications/android-sdk-macosx
If you installed Android Studio, the value will need to be
如果您安装了Android Studio,则该值需要为
export ANDROID_HOME=$HOME/Library/Android/sdk
Linux
Linux
$ export ANDROID_HOME=~/android-sdk-linux
Then add the paths to the platform-tools
and tools
sub-directories (Same on MacOS/Linux).
然后添加到platform-tools
和tools
子目录的路径(在 MacOS/Linux 上相同)。
export PATH=$ANDROID_HOME/tools:$PATH
export PATH=$ANDROID_HOME/platform-tools:$PATH
You should now be able to run android
from the shell.
您现在应该可以android
从 shell运行了。
If none of the suggested ANDROID_HOME paths above are valid, you can find the (uniquely and consistently named) platform-tools folder via:
如果以上建议的 ANDROID_HOME 路径均无效,您可以通过以下方式找到(唯一且一致命名的)platform-tools 文件夹:
find / -name platform-tools 2>/dev/null
Whatever path that returns will need to be trimmed down to end with either sdk
, android-sdk-linux
, or android-sdk-macosx
.
无论路径的回报将需要下调,以结束与任sdk
,android-sdk-linux
或android-sdk-macosx
。
回答by Blackbelt
That's because your platforms
and platform-tools
are not in the PATH
environment variable. You can run the adb
command with path-to-adb/adb
or add platforms
and platform-tools
to PATH
and run typing only adb
那是因为您的platforms
和platform-tools
不在PATH
环境变量中。您可以运行adb
与命令path-to-adb/adb
或加platforms
和platform-tools
来 PATH
和运行仅输入adb
This is my path environment variable:
这是我的路径环境变量:
PATH=/usr/local/bin:/usr/bin:/bin:/opt/bin:/usr/x86_64-pc-linux-gnu/gcc-bin/4.5.3:/opt/android-sdk-update-manager/tools:/opt/android-sdk-update-manager/platform-tools
回答by Erich Douglass
Assuming that you have set ANDROID_HOME
to point to the sdk install, you should add $ANDROID_HOME/tools
and $ANDROID_HOME/platform-tools
to your PATH
.
假设您已设置ANDROID_HOME
指向 sdk 安装,您应该将$ANDROID_HOME/tools
和添加$ANDROID_HOME/platform-tools
到您的PATH
.
回答by possumkeys
Another possibility is simply that your "android" file is not executable. Navigate to the tools path in terminal and then make it executable by:
chmod 777 android
Then you can run:
./android sdk
It's what worked for me.
另一种可能性是您的“android”文件不可执行。导航到终端中的工具路径,然后通过以下方式使其可执行:
chmod 777 android
然后您可以运行:
./android sdk
这对我有用。
回答by James Tan
android is now inside android-sdks/tools
android 现在在 android-sdks/tools 里面
if you are using mac, you may set your .bash_profile to include it.
如果您使用的是 mac,您可以将 .bash_profile 设置为包含它。
PATH=$PATH:[android-sdks]/platform-tools:[android-sdks]/tools
回答by cyonder
For Mac, go into your home directory by typing cd ~
, and then type vi .bash_profile
, This file might be empty or just created, and this is not a problem.
对于 Mac,键入 进入您的主目录cd ~
,然后键入vi .bash_profile
,此文件可能为空或刚刚创建,这不是问题。
To edit the file, press i
on your keyboard and inside the file, type the following path:
要编辑文件,请按i
键盘上的 并在文件内键入以下路径:
export PATH="/Users/YOUR-USERNAME-HERE/Library/Android/sdk/platform-tools":$PATH
export PATH="/Users/YOUR-USERNAME-HERE/Library/Android/sdk/tools":$PATH
When you are done, press esc
, and again press shift :
and type wq
. Okay, now you saved your file. Now, quit terminal and re-launch, and try typing:
完成后,按esc
,然后再次按shift :
并键入wq
。好的,现在您保存了文件。现在,退出终端并重新启动,然后尝试输入:
adb -h
android -h
If both commands are giving you output, it means everything works fine.
如果两个命令都为您提供输出,则意味着一切正常。
Not: We used vi
command to edit the file. If you got confused with this command, you can also try nano
for editing the file.
不是:我们使用vi
命令来编辑文件。如果您对这个命令感到困惑,您也可以尝试nano
编辑该文件。
回答by Abdul Mannan
Sometimes even after you add your android_sdk/
dir path from command line it still doesn't work and gives the command not found error
, in that case follow these steps. I ran through this issue myself and i tried all the above steps and none worked so i thought i should share and perhaps that might help somebody.
( android-sdk-linux is the name of android sdk library which you have extracted).
有时即使在您android_sdk/
从命令行添加目录路径后,它仍然不起作用并给出command not found error
,在这种情况下,请按照以下步骤操作。我自己解决了这个问题,我尝试了上述所有步骤,但都没有奏效,所以我想我应该分享一下,也许这可能会对某人有所帮助。
(android-sdk-linux 是您提取的 android sdk 库的名称)。
1) Open the bashrc file from command line
1) 从命令行打开 bashrc 文件
gedit ~/.bashrc
2) Add following lines at the top.
2) 在顶部添加以下几行。
export PATH=${PATH}:~/android-sdk-linux/tools
export PATH=${PATH}:~/android-sdk-linux/platform-tools
3) Log out of the system and log back in. Type Ctrl+ Alt+ Tto open command line and type androidto launch the software.
3)退出系统并重新登录。键入Ctrl+ Alt+ T,以打开命令行和类型的android以启动该软件。
回答by Karl Adler
After installing Android studio. Create or edit your ~/.bashrc file and add the following lines:
安装Android Studio 后。创建或编辑您的 ~/.bashrc 文件并添加以下行:
export ANDROID_HOME=~/Android/Sdk
export PATH=${PATH}:${ANDROID_HOME}/tools
and reload .bashrc
并重新加载 .bashrc
source ~/.bashrc
回答by Emil Namen
Uninstall cask android-platform-tools
brew cask uninstall android-platform-tools
Install it using Android Studio
卸载 cask android-platform-tools
brew cask uninstall android-platform-tools
使用 Android Studio 安装