Android Studio的安装 环境搭建

JDK下载:https://www.oracle.com/java/technologies/downloads/#java8
选择自己的对应的版本下载。
![image.png](https://img-blog.csdnimg.cn/img_convert/d2dbe3db9a7a0a7d08de487c127327ff.png#clientId=u236fa0bd-be1f-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=518&id=u125b62a3&margin=[object Object]&name=image.png&originHeight=1036&originWidth=2582&originalType=binary&ratio=1&rotation=0&showTitle=false&size=220052&status=done&style=none&taskId=ub3c0de93-e9fb-4c97-b25f-dd02b85c0af&title=&width=1291)
下载完文件之后打开文件,就会出现安装向导,一般是一路next点击下去。

JDK相关的环境变量。

Mac配置JDK:

配置环境之前我们必须要清楚这个JDK的安装路径,这个是配置环境变量的关键,如果不知道,请在terminal输入以下字符串来查询:

/usr/libexec/java_home -V

![image.png](https://img-blog.csdnimg.cn/img_convert/46fc058646a6b50102500dc47df28f59.png#clientId=u236fa0bd-be1f-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=103&id=u49d7bbb7&margin=[object Object]&name=image.png&originHeight=206&originWidth=1140&originalType=binary&ratio=1&rotation=0&showTitle=false&size=58267&status=done&style=none&taskId=u6108ee60-e96f-499b-b856-18249fc4bbe&title=&width=570)
输入以上字符串,就会输出JDK的安装路径,将这个路径复制暂且复制下来,一会儿用。

然后接下来我们在terminal输入相应的语句:如果我们是第一次配置环境变量,请输入touch .bash_profile,会创建一个 .bash_profile的隐藏文件,但是如果你不是第一次配置环境变量的话,请直接使用open -e .bash_profile 或者open ~/.bash_profile命令打开。
**注意:**文件名必须是 .bash_profile, 并且 touch .bash_profile, open .bash_profile, source .bash_profile 这类命令行必须在Home路径下面进行。 Terminal 程序在被打开的时候就默认在Home路径下面。但是如果当前不在Home路径下面,需要返回到Home路径下面进行。
系统在最开始的时候会自动读取~/.bash_profile 也就是Home文件下的指定文件。所以这要求我们必须写在Home文件下,且名字必须是bash_profile。

open ~/.bash_profile打开是这样:
![image.png](https://img-blog.csdnimg.cn/img_convert/3a684411cea048bea2443f3501a38eab.png#clientId=u99381fa1-b15b-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=118&id=u648120ae&margin=[object Object]&name=image.png&originHeight=236&originWidth=1354&originalType=binary&ratio=1&rotation=0&showTitle=false&size=55225&status=done&style=none&taskId=ue7ca186e-755f-4890-a12d-0ab1b736769&title=&width=677)
首先,第一个参数,JAVA_HOME,这句要自己写

JAVA_HOME=jdk路径

JAVA_HOME 就是JDK的安装路径,这个路径因为每个人安装JDK时设置的安装目录不同而有所不同。将刚才复制的文字粘贴到这里来,基本上就是正确的。但是如果当前的安装路径出现空格之类的特殊字符,记住一定要加上转义字符!
然后其他的几句,复制以下内容:

PATH=$JAVA_HOME/bin:$PATH:.
CLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar:.
export JAVA_HOME
export PATH
export CLASSPATH

写完后保存文件并关闭。
然后回到terminal, 使用source .bash_profile 使刚刚写的配置生效。

最后我们可以在终端中输入 java -version语句来确认配置是否生效:![image.png](https://img-blog.csdnimg.cn/img_convert/4d76d68c3555220579ac867329e06129.png#clientId=u236fa0bd-be1f-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=75&id=u83b03a99&margin=[object Object]&name=image.png&originHeight=150&originWidth=1018&originalType=binary&ratio=1&rotation=0&showTitle=false&size=36725&status=done&style=none&taskId=uea55085a-c1bf-4038-bc0f-9370e5ddae3&title=&width=509)

Windows配置JDK:

1.Windows环境变量修改:点击计算机图标 - 属性 - 高级系统设置 - 高级 - 环境变量

![image.png](https://img-blog.csdnimg.cn/img_convert/8752693773e48331964b7a293e4266b0.png#clientId=u53ad8cc6-0c5b-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=337&id=u0fdd7ee2&margin=[object Object]&name=image.png&originHeight=1000&originWidth=1280&originalType=binary&ratio=1&rotation=0&showTitle=false&size=59184&status=done&style=none&taskId=u728e295b-ab4f-4ce2-9816-e829e86cd70&title=&width=431)

2.新建一个变量名叫:JAVA_HOM :值是jdk路径。

![image.png](https://img-blog.csdnimg.cn/img_convert/9e05e4abde439673279faa347ea365e0.png#clientId=u53ad8cc6-0c5b-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=157&id=SJE8a&margin=[object Object]&name=image.png&originHeight=313&originWidth=761&originalType=binary&ratio=1&rotation=0&showTitle=false&size=13940&status=done&style=none&taskId=u5ebb9170-6def-4114-9dd0-b2f3d67adcf&title=&width=380.5)

3.双击打开path。

![image.png](https://img-blog.csdnimg.cn/img_convert/fc29a6e71060b0fbf67fe9cd94b6c9ff.png#clientId=u53ad8cc6-0c5b-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=157&id=u58673f75&margin=[object Object]&name=image.png&originHeight=313&originWidth=761&originalType=binary&ratio=1&rotation=0&showTitle=false&size=16398&status=done&style=none&taskId=u3fc2d083-0f02-4a54-9886-dbac9343e91&title=&width=380.5)

4.新建2个以下的路径。

%JAVA_HOME%\bin
%JAVA_HOME%\jre\bin

![image.png](https://img-blog.csdnimg.cn/img_convert/3dc32c172d724bfe51a2e57313c93e7b.png#clientId=u53ad8cc6-0c5b-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=478&id=u3e5c4305&margin=[object Object]&name=image.png&originHeight=1326&originWidth=1334&originalType=binary&ratio=1&rotation=0&showTitle=false&size=271451&status=done&style=none&taskId=u73879149-2bf0-43ba-adff-53fff232916&title=&width=481)

5.点击确认退出,再次确认保存当前环境变量。

Android Studio环境的配置:

macOS AS环境变量

![image.png](https://img-blog.csdnimg.cn/img_convert/947e0562964d062575c6b23236fcd65a.png#clientId=u53ad8cc6-0c5b-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=74&id=AJbi4&margin=[object Object]&name=image.png&originHeight=148&originWidth=1372&originalType=binary&ratio=1&rotation=0&showTitle=false&size=42095&status=done&style=none&taskId=u0265beb2-90ce-48ad-89ec-82803502b9d&title=&width=686)

  1. open ~/.bash_profile文件
  2. ANDROID_HOME需要写上本地的android sdk文件路径
  3. 直接复制以下代码并保存
  4. 新建终端输入 source .bash_profile
export ANDROID_HOME= android sdk文件路径
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/platform-tools

Windows AS环境变量

1.Windows环境变量修改:点击计算机图标 - 属性 - 高级系统设置 - 高级 - 环境变量

![image.png](https://img-blog.csdnimg.cn/img_convert/a2350119a8fa0db8126e67046a98146f.png#clientId=u53ad8cc6-0c5b-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=500&id=ufd5806ca&margin=[object Object]&name=image.png&originHeight=1000&originWidth=1280&originalType=binary&ratio=1&rotation=0&showTitle=false&size=59184&status=done&style=none&taskId=uaa8406c9-d8bc-403e-a746-5a99526f384&title=&width=640)

2.新建一个变量名叫:ANDROID_HOME :值是Android SDK路径。

![image.png](https://img-blog.csdnimg.cn/img_convert/bdfa1055577b73631414b4c3b4323060.png#clientId=u53ad8cc6-0c5b-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=157&id=u484f73f5&margin=[object Object]&name=image.png&originHeight=313&originWidth=761&originalType=binary&ratio=1&rotation=0&showTitle=false&size=17875&status=done&style=none&taskId=u6c466735-5a55-425e-b3a9-cad0264b377&title=&width=380.5)

3.双击打开path。

![image.png](https://img-blog.csdnimg.cn/img_convert/ed314387e48ee2a469e1d5f00555837d.png#clientId=u53ad8cc6-0c5b-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=157&id=u4d860d6c&margin=[object Object]&name=image.png&originHeight=313&originWidth=761&originalType=binary&ratio=1&rotation=0&showTitle=false&size=25402&status=done&style=none&taskId=u6f8dba0d-c353-4bb7-bfe2-0e72a907753&title=&width=380.5)

4.新建2个以下的路径。

%ANDROID_HOME%\tools
%JAVA_HOME%\jre\bin

![image.png](https://img-blog.csdnimg.cn/img_convert/9922db1914253a71261cd809d2814b76.png#clientId=u53ad8cc6-0c5b-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=578&id=u5c386f95&margin=[object Object]&name=image.png&originHeight=1338&originWidth=1354&originalType=binary&ratio=1&rotation=0&showTitle=false&size=275967&status=done&style=none&taskId=uf1a54082-6d02-4ec0-880e-c65bb927b6a&title=&width=585)

5.点击确认退出,再次确认保存当前环境变量。

Android Studio的下载 :

官网地址:官网链接地址
中文地址:国内中文链接地址

安装

![image.png](https://img-blog.csdnimg.cn/img_convert/196a8df065a746faf101a2906b19feba.png#clientId=u236fa0bd-be1f-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=486&id=uaa8728ca&margin=[object Object]&name=image.png&originHeight=974&originWidth=1240&originalType=binary&ratio=1&rotation=0&showTitle=false&size=357783&status=done&style=none&taskId=ua23efdfd-6de9-40b3-84cc-bbb463a8384&title=&width=619)

一路next就好 傻瓜式安装 安装路径不要带中文
![image.png](https://img-blog.csdnimg.cn/img_convert/c46193f69a2ee1f729b9c4e4e913c080.png#clientId=u236fa0bd-be1f-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=488&id=uaea99405&margin=[object Object]&name=image.png&originHeight=976&originWidth=1246&originalType=binary&ratio=1&rotation=0&showTitle=false&size=212287&status=done&style=none&taskId=u444ab6fe-5a7c-459f-9390-5cccba14968&title=&width=623)

基本设置

![image.png](https://img-blog.csdnimg.cn/img_convert/c26bca6585c0320ec709ac44bd26d5d4.png#clientId=u236fa0bd-be1f-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=283&id=ufcf9d5d1&margin=[object Object]&name=image.png&originHeight=212&originWidth=467&originalType=binary&ratio=1&rotation=0&showTitle=false&size=13995&status=done&style=none&taskId=uf669e7d7-7c6e-40b1-b425-edb476b4fa9&title=&width=623.5)

接下来,正常操作。出现下面报错
这里报错原因是你电脑没有SDK而且你下载的android studio又是不带SDK的
这里我们先选cancel 跳过一下 后面在设置添加SDK
![image.png](https://img-blog.csdnimg.cn/img_convert/c554db5e48efb5536ebcd7b26c545bc4.png#clientId=u236fa0bd-be1f-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=227&id=ue7499b57&margin=[object Object]&name=image.png&originHeight=145&originWidth=400&originalType=binary&ratio=1&rotation=0&showTitle=false&size=11626&status=done&style=none&taskId=ub62f3f02-53cf-4e94-aab2-ae019909bb1&title=&width=626)

选择jdk 这里AS自带了一个内部的jdk 也可以选择本地已有的jdk。
安装SDK默认全选
安装路径不要带中文和空格
![image.png](https://img-blog.csdnimg.cn/img_convert/c000d6f30dc18c4b719ec672ecae127d.png#clientId=u236fa0bd-be1f-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=477&id=udcd22457&margin=[object Object]&name=image.png&originHeight=742&originWidth=984&originalType=binary&ratio=1&rotation=0&showTitle=false&size=57878&status=done&style=none&taskId=uab46c834-da27-4b67-b2aa-5232fbb18b1&title=&width=633)

分配内存 默认2GB
最好不要低于2GB 内存大的可以多分配一点
![image.png](https://img-blog.csdnimg.cn/img_convert/d01789ab09f551dccc1519cbe88b7620.png#clientId=u236fa0bd-be1f-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=474&id=ucd1d7fea&margin=[object Object]&name=image.png&originHeight=742&originWidth=984&originalType=binary&ratio=1&rotation=0&showTitle=false&size=55445&status=done&style=none&taskId=u25346a21-5246-4906-9081-8132ce93e26&title=&width=629)

点击finish开始下载 下载有点慢
![image.png](https://img-blog.csdnimg.cn/img_convert/a7ad569c22666d7afa3c8f12fb1322a6.png#clientId=u236fa0bd-be1f-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=476&id=uc0ce1166&margin=[object Object]&name=image.png&originHeight=742&originWidth=984&originalType=binary&ratio=1&rotation=0&showTitle=false&size=55132&status=done&style=none&taskId=u8c115e5f-0687-499c-8137-aa9aabc4d52&title=&width=631)

创建一个工程 demo 写一个hello world
![image.png](https://img-blog.csdnimg.cn/img_convert/8f1c0304355d678bd5772bc53dec70c2.png#clientId=u236fa0bd-be1f-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=461&id=ue833f26a&margin=[object Object]&name=image.png&originHeight=605&originWidth=822&originalType=binary&ratio=1&rotation=0&showTitle=false&size=42835&status=done&style=none&taskId=u0b73cc83-68e3-432c-bea1-2fa921d2852&title=&width=626)

根据需要选择模板,这里演示选择空白模板
![image.png](https://img-blog.csdnimg.cn/img_convert/09f3f0b51445d9c8d0b73c36e0075a35.png#clientId=u236fa0bd-be1f-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=454&id=uffcc609f&margin=[object Object]&name=image.png&originHeight=813&originWidth=1127&originalType=binary&ratio=1&rotation=0&showTitle=false&size=69856&status=done&style=none&taskId=u8e64a711-974b-490f-bcb2-3377092a173&title=&width=629.5)

项目名称,域名,语言,API等级,根据需要选择就好
![image.png](https://img-blog.csdnimg.cn/img_convert/80de58f3f6af0e9f867231b87e645a96.png#clientId=u236fa0bd-be1f-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=451&id=uf66dd8a0&margin=[object Object]&name=image.png&originHeight=813&originWidth=1127&originalType=binary&ratio=1&rotation=0&showTitle=false&size=57985&status=done&style=none&taskId=u2eb68c13-3c8e-41e7-a835-e66a5a98653&title=&width=624.5)

由于第一次安装不能运行,需要配置一个新的模拟器,或者使用真机。
![image.png](https://img-blog.csdnimg.cn/img_convert/f6de193ea6bae089754b3dfcb24499f1.png#clientId=u236fa0bd-be1f-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=69&id=u2e44ae65&margin=[object Object]&name=image.png&originHeight=50&originWidth=460&originalType=binary&ratio=1&rotation=0&showTitle=false&size=8401&status=done&style=none&taskId=u09b2e7ca-5aba-4cc3-9564-f8c39aa59ea&title=&width=637)

创建一个新的虚拟设备
![image.png](https://img-blog.csdnimg.cn/img_convert/a19dcc9c38c4b75f572e5d63c92253fd.png#clientId=u236fa0bd-be1f-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=76&id=u6e61f157&margin=[object Object]&name=image.png&originHeight=37&originWidth=241&originalType=binary&ratio=1&rotation=0&showTitle=false&size=5349&status=done&style=none&taskId=ua4b36d7b-f0b0-48d6-96bb-77db4309299&title=&width=496.5)

选择一个型号进行下载
![image.png](https://img-blog.csdnimg.cn/img_convert/e7d8809301a91f8caeb029fdabc72f1e.png#clientId=u236fa0bd-be1f-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=348&id=uce9c6773&margin=[object Object]&name=image.png&originHeight=337&originWidth=255&originalType=binary&ratio=1&rotation=0&showTitle=false&size=36841&status=done&style=none&taskId=ue3238e02-c1f4-4be4-b1b8-ffc9606f456&title=&width=263.5)

![image.png](https://img-blog.csdnimg.cn/img_convert/a82c7139c75fbfb2498ed6c7916207c4.png#clientId=u236fa0bd-be1f-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=462&id=ua5597a0c&margin=[object Object]&name=image.png&originHeight=813&originWidth=1252&originalType=binary&ratio=1&rotation=0&showTitle=false&size=74511&status=done&style=none&taskId=u006dc001-c28c-4e24-8f04-b3198b82ce2&title=&width=712)

![image.png](https://img-blog.csdnimg.cn/img_convert/ca340f68bb351548726d62d4b19dd666.png#clientId=u236fa0bd-be1f-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=499&id=ud3220c7f&margin=[object Object]&name=image.png&originHeight=813&originWidth=1127&originalType=binary&ratio=1&rotation=0&showTitle=false&size=64465&status=done&style=none&taskId=u86daf7c4-16ce-4bfe-9a4e-f6ad6437c90&title=&width=691.5)

![image.png](https://img-blog.csdnimg.cn/img_convert/1cd300196f5b67d1582c489de8657d5a.png#clientId=u236fa0bd-be1f-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=497&id=u7b5837fd&margin=[object Object]&name=image.png&originHeight=813&originWidth=1127&originalType=binary&ratio=1&rotation=0&showTitle=false&size=72572&status=done&style=none&taskId=uc4a6e641-103a-47b1-9ca3-01baff99472&title=&width=688.5)

完成安装
![image.png](https://img-blog.csdnimg.cn/img_convert/cf13a1cdce6ba0e7d38bde8ceb049880.png#clientId=u236fa0bd-be1f-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=361&id=u752ccf62&margin=[object Object]&name=image.png&originHeight=722&originWidth=1484&originalType=binary&ratio=1&rotation=0&showTitle=false&size=47273&status=done&style=none&taskId=ub9615e70-b803-415c-86ee-5b82c6a8fa8&title=&width=742)

运行虚拟设备
![image.png](https://img-blog.csdnimg.cn/img_convert/c57130956b9cc3d9e338e47f5abf36fe.png#clientId=u236fa0bd-be1f-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=688&id=uadc9ba6a&margin=[object Object]&name=image.png&originHeight=835&originWidth=472&originalType=binary&ratio=1&rotation=0&showTitle=false&size=201775&status=done&style=none&taskId=u205e8db3-3bfb-4504-9bc2-e1184fcb84e&title=&width=389)

运行我们的程序成功出现 hello world

![image.png](https://img-blog.csdnimg.cn/img_convert/aab6ebf259b56e198cf7b19b76fe169c.png#clientId=u236fa0bd-be1f-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=761&id=u9c6df5cf&margin=[object Object]&name=image.png&originHeight=821&originWidth=398&originalType=binary&ratio=1&rotation=0&showTitle=false&size=47201&status=done&style=none&taskId=u59e2bc2c-7d91-4abb-ab41-d77a2e33d91&title=&width=369)

Android SDK下载:

![image.png](https://img-blog.csdnimg.cn/img_convert/ecb521fbb0c45f8a3a8af4f6bb7b210a.png#clientId=ud68734b5-1623-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=900&id=uc8f80eee&margin=[object Object]&name=image.png&originHeight=1800&originWidth=2432&originalType=binary&ratio=1&rotation=0&showTitle=false&size=605751&status=done&style=none&taskId=u1ec68b90-6dc6-4491-ba9a-53773efac5a&title=&width=1216)

配置Flutter SDk路径。

![image.png](https://img-blog.csdnimg.cn/img_convert/b95c186a72efee60b25c6ee917272fbf.png#clientId=ud68734b5-1623-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=900&id=SYQYj&margin=[object Object]&name=image.png&originHeight=1800&originWidth=2432&originalType=binary&ratio=1&rotation=0&showTitle=false&size=399773&status=done&style=none&taskId=u1c23ecdc-1f8e-4aa2-81cd-0c8ba60f2ac&title=&width=1216)

配置Dart SDK路径。

![image.png](https://img-blog.csdnimg.cn/img_convert/cc2ae60954bfeaef5a6e2522d605edfe.png#clientId=ud68734b5-1623-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=900&id=u1e19fba4&margin=[object Object]&name=image.png&originHeight=1800&originWidth=2432&originalType=binary&ratio=1&rotation=0&showTitle=false&size=307102&status=done&style=none&taskId=u25bd4ed7-5323-4de7-9451-7f369943f86&title=&width=1216)

插件的安装:

![image.png](https://img-blog.csdnimg.cn/img_convert/ef7d0baf3a02c3d7d36a68986fd2fd30.png#clientId=u99381fa1-b15b-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=368&id=ufecc3b8a&margin=[object Object]&name=image.png&originHeight=559&originWidth=981&originalType=binary&ratio=1&rotation=0&showTitle=false&size=299597&status=done&style=none&taskId=u684a492e-5f01-4457-bf1b-985fffa1c22&title=&width=646.5)
![image.png](https://img-blog.csdnimg.cn/img_convert/8f3fb64b9ae605ecf13d6708b56a8c61.png#clientId=u99381fa1-b15b-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=471&id=u480bb07f&margin=[object Object]&name=image.png&originHeight=516&originWidth=709&originalType=binary&ratio=1&rotation=0&showTitle=false&size=197595&status=done&style=none&taskId=u2af7f7b5-2a00-45aa-a462-1755cb1b51c&title=&width=647.5)

安装好后重启

![image.png](https://img-blog.csdnimg.cn/img_convert/256a53879d16a2a45244fc20b3fd5aab.png#clientId=u53ad8cc6-0c5b-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=490&id=u2e904c19&margin=[object Object]&name=image.png&originHeight=1134&originWidth=1182&originalType=binary&ratio=1&rotation=0&showTitle=false&size=117092&status=done&style=none&taskId=u85ff90c8-2b31-4c61-b271-76f6ffe228d&title=&width=511)


版权声明:本文为hzqit520原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
THE END
< <上一篇
下一篇>>