如何在 ubuntu 中设置 ANDROID_HOME 路径?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26256279/
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
How to set ANDROID_HOME path in ubuntu?
提问by HillHacker
How to set ANDROID_HOME path in ubuntu?
如何在 ubuntu 中设置 ANDROID_HOME 路径?
Please provide the steps.
请提供步骤。
回答by Dario Quintana
In the console just type these :
在控制台中输入这些:
export ANDROID_HOME=$HOME/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/tools
If you want to make it permanent just add those lines in the ~/.bashrc file
如果你想让它永久化,只需在 ~/.bashrc 文件中添加这些行
回答by Jordan Jambazov
I would like to share an answer that also demonstrates approach using the Android SDK provided by the Ubuntu repository:
我想分享一个答案,该答案也演示了使用 Ubuntu 存储库提供的 Android SDK 的方法:
Install Android SDK
安装安卓SDK
sudo apt-get install android-sdk
Export environmental variables
导出环境变量
export ANDROID_HOME="/usr/lib/android-sdk/"
export PATH="${PATH}:${ANDROID_HOME}tools/:${ANDROID_HOME}platform-tools/"
回答by All ?? Vаи?тy
Assuming you have the sdk extracted at ~/Android/Sdk
,
假设您在~/Android/Sdk
,
export ANDROID_HOME=$HOME/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/platform-tools
Add the above lines to the file
~/.bashrc
(located athome/username/.bashrc
) to make it permanent for the current user. Runsource ~/.bashrc
to apply the changes or restart your terminal.(or)
Run the above lines on a terminal window to make it available for the session.
将以上几行添加到文件
~/.bashrc
(位于home/username/.bashrc
)以使其对当前用户永久有效。运行source ~/.bashrc
以应用更改或重新启动终端。(或)
在终端窗口上运行以上行以使其可用于会话。
To test if you have set it up correctly,
要测试您是否正确设置,
Run the below commands on a terminal window
在终端窗口上运行以下命令
echo $ANDROID_HOME
user@host:~$ echo $ANDROID_HOME /home/<user>/Android/Sdk
which android
user@host:~$ which android /home/<user>/Android/Sdk/tools/android
Run
android
on a terminal window, If it opens up Android SDK Manager, you are good to go.
echo $ANDROID_HOME
user@host:~$ echo $ANDROID_HOME /home/<user>/Android/Sdk
which android
user@host:~$ which android /home/<user>/Android/Sdk/tools/android
android
在终端窗口上运行,如果它打开Android SDK Manager,你就可以开始了。
回答by user2768310
better way is to reuse ANDROID_HOME variable in path variable. if your ANDROID_HOME variable changes you just have to make change at one place.
更好的方法是在路径变量中重用 ANDROID_HOME 变量。如果您的 ANDROID_HOME 变量发生变化,您只需在一处进行更改。
export ANDROID_HOME=/home/arshid/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
回答by Sudhir Khanger
Add the following to your ~/.bashrc
file. Log-out and log-in. I have my sdk in $HOME/Documents/Android/sdk
you have to replace it with where you keep your sdk folder
将以下内容添加到您的~/.bashrc
文件中。注销和登录。我有我的 sdk,$HOME/Documents/Android/sdk
你必须用你保存 sdk 文件夹的地方替换它
# Android Path
PATH=$PATH:$HOME/Documents/Android/sdk:$HOME/Documents/Android/sdk/tools
export PATH
# For SDK version r_08 and higher, also add this for adb:
PATH=$PATH:$HOME/Documents/Android/sdk/platform-tools
export PATH
回答by varun
Initially go to your home and press Ctrl+ Hit will show you hidden files now look for .bashrc
file, open it with any text editor then place below lines at the end of file.
最初去你的家并按Ctrl+H它将显示隐藏文件现在查找.bashrc
文件,使用任何文本编辑器打开它然后将其放在文件末尾的下面几行。
export ANDROID_HOME=/home/varun/Android/Sdk
export PATH=$PATH:/home/varun/Android/Sdk/tools
export PATH=$PATH:/home/varun/Android/Sdk/platform-tools
Please change /home/varun/Android/Sdk
path to your SDK path.
Do the same for tools and platform-tools.
请将/home/varun/Android/Sdk
路径更改为您的 SDK 路径。对工具和平台工具执行相同的操作。
After this save .bashrc
file and close it.
在此保存.bashrc
文件并关闭它之后。
Now you are ready to use ADB commands on terminal.
现在您已准备好在终端上使用 ADB 命令。
回答by Aashish
first open the .bashrc file by gedit ~/.bashrc
首先通过 gedit ~/.bashrc 打开 .bashrc 文件
# Added ANDROID_HOME variable. export ANDROID_HOME=$HOME/Android/Sdk export PATH=$PATH:$ANDROID_HOME/tools export PATH=$PATH:$ANDROID_HOME/platform-tools
# Added ANDROID_HOME variable. export ANDROID_HOME=$HOME/Android/Sdk export PATH=$PATH:$ANDROID_HOME/tools export PATH=$PATH:$ANDROID_HOME/platform-tools
save the file and reopen the terminal
保存文件并重新打开终端
echo $ANDROID_HOME
echo $ANDROID_HOME
it will show the path like /home/pathTo/Android/Sdk
它会显示路径 /home/pathTo/Android/Sdk
回答by Giovanny Gonzalez
Applies to Ubuntu and Linux Mint
适用于 Ubuntu 和 Linux Mint
In the archive:
在存档中:
sudo nano .bashrc
Add to the end:
添加到最后:
export ANDROID_HOME=${HOME}/Android/Sdk
export PATH=${PATH}:${ANDROID_HOME}/platform-tools:${ANDROID_HOME}/tools
Restart the terminal and doing: echo $ HOME or $ PATH, you can know these variables.
重新启动终端并执行:echo $HOME 或 $PATH,就可以知道这些变量了。
回答by Aman Kumar Gupta
In the terminal just type these 3 commands to set the ANDROID_HOME Variable :
在终端中输入这 3 个命令来设置 ANDROID_HOME 变量:
$ export ANDROID_HOME=~/Android/Sdk
/Android/Sdk
is the location of Sdk, this might get change in your case
/Android/Sdk
是 Sdk 的位置,这可能会改变你的情况
$ PATH=$PATH:$ANDROID_HOME/tools
$ PATH=$PATH:$ANDROID_HOME/platform-tools `
Note :This will set the path temporarily so what ever action you have to perform, perform on the same terminal.
注意:这将临时设置路径,因此您必须执行的任何操作都在同一终端上执行。
回答by Atif Mukhtiar
I was facing the same problem with linux ANDROID_HOME path
我在 linux ANDROID_HOME 路径上遇到了同样的问题
Note:
1- Add parameters2- Make or Rebuild project
3- Restart your PC
注意:
1- 添加参数2- 制作或重建项目
3-重启你的电脑
How to add parameters using terminal:
如何使用终端添加参数:
Open your terminal write
打开你的终端写
gedit .bashrc
编辑 .bashrc
another window will be open and then add the following lines at the end of the windows.
将打开另一个窗口,然后在窗口末尾添加以下行。
export ANDROID_HOME=$HOME/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/platform-tools
then back to terminal and type
然后回到终端并输入
source .bashrc
源.bashrc
to save your changes in bashrc file at the end restart your computer.
最后将更改保存在 bashrc 文件中,然后重新启动计算机。