## 1.下载
### 1.1 JDK 下载
官网下载地址:https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
同意协议后,下载相应 JDK 版本。
![](https://img-blog.csdnimg.cn/20200225170743445.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3UwMTQ3MjAwMjI=,size_16,color_FFFFFF,t_70)
### 1.2 AS 下载
官网下载地址:https://developer.android.google.cn/studio/
目前最新版本是:V4.2.1
## 2.安装
### 2.1 安装 JDK
![](https://img-blog.csdnimg.cn/20200225170855841.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3UwMTQ3MjAwMjI=,size_16,color_FFFFFF,t_70)
### 2.2 安装 Android Studio
- 安装的欢迎页面,下一步
![](https://img-blog.csdnimg.cn/2020022517145889.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3UwMTQ3MjAwMjI=,size_16,color_FFFFFF,t_70)
- 选择AS的组件,默认选上Android手机模拟器
![](https://img-blog.csdnimg.cn/20200225171513571.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3UwMTQ3MjAwMjI=,size_16,color_FFFFFF,t_70)
- 配置设置,为了方便,重新设置路径。(注意!!!安装过程中,路径中文件夹或者目录都不能带有中文或者空格!不然后面可能会导致编译出错!)
![](https://img-blog.csdnimg.cn/20200225171530460.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3UwMTQ3MjAwMjI=,size_16,color_FFFFFF,t_70)
- 创建AS的桌面快捷方式,默认需要
![](https://img-blog.csdnimg.cn/2020022517154258.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3UwMTQ3MjAwMjI=,size_16,color_FFFFFF,t_70)
- 安装完成,启动
![](https://img-blog.csdnimg.cn/20200225171559261.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3UwMTQ3MjAwMjI=,size_16,color_FFFFFF,t_70)
![](https://img-blog.csdnimg.cn/20200225171612398.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3UwMTQ3MjAwMjI=,size_16,color_FFFFFF,t_70)
- 是否需要导入以前AS的配置设置,默认不需要,进入加载
![](https://img-blog.csdnimg.cn/20200225171621993.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3UwMTQ3MjAwMjI=,size_16,color_FFFFFF,t_70)
- 无法访问 android sdk 插件列表
![](https://img-blog.csdnimg.cn/20200225171648535.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3UwMTQ3MjAwMjI=,size_16,color_FFFFFF,t_70)
- 选择 cancel ,进入到了安装向导,下一步
![](https://img-blog.csdnimg.cn/2020022517170036.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3UwMTQ3MjAwMjI=,size_16,color_FFFFFF,t_70)
- 为 android studio 选择想要的设置类型
![](https://img-blog.csdnimg.cn/20200225171738464.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3UwMTQ3MjAwMjI=,size_16,color_FFFFFF,t_70)
- 选择UI的主题,推荐极客黑,护眼
![](https://img-blog.csdnimg.cn/20200225171738464.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3UwMTQ3MjAwMjI=,size_16,color_FFFFFF,t_70)
- SDK 组件安装,修改SDK的路径
![](https://img-blog.csdnimg.cn/20200225171745936.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3UwMTQ3MjAwMjI=,size_16,color_FFFFFF,t_70)
- 启动欢迎页面
![](https://img-blog.csdnimg.cn/20200225171825951.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3UwMTQ3MjAwMjI=,size_16,color_FFFFFF,t_70)
## 3. 配置JDK及JAVA的环境
### 3.1 打开系统环境
![](https://img-blog.csdnimg.cn/20200225171035476.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3UwMTQ3MjAwMjI=,size_16,color_FFFFFF,t_70)
- 打开环境变量
![](https://img-blog.csdnimg.cn/20200225171056143.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3UwMTQ3MjAwMjI=,size_16,color_FFFFFF,t_70)
- 复制jdk的路径,也就是我们前面安装JDK时设置的路径
![](https://img-blog.csdnimg.cn/20200225171108609.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3UwMTQ3MjAwMjI=,size_16,color_FFFFFF,t_70)
### 3.2 配置 JAVA_HOME
变量名:JAVA_HOME
变量值:JDK安装目录(C:\Java\jdk1.8.0_202)
![](https://img-blog.csdnimg.cn/20200225171202141.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3UwMTQ3MjAwMjI=,size_16,color_FFFFFF,t_70)
### 3.3 配置 CLASSPATH
变量名:CLASSPATH
变量值:.;%JAVA_HOME%\lib;%JAVA_HOME%\lib\tools.jar;
![](https://img-blog.csdnimg.cn/2020022517123525.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3UwMTQ3MjAwMjI=,size_16,color_FFFFFF,t_70)
### 3.4 编辑 path
变量名:Path
变量值:;%JAVA_HOME%\bin;%JAVA_HOME%\jre\bin;
Path为系统中的变量不需要新建,直接选择Path进行编辑,弹窗后选择编辑文本,再确认
![](https://img-blog.csdnimg.cn/20200225171256193.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3UwMTQ3MjAwMjI=,size_16,color_FFFFFF,t_70)
### 3.5 确认
- 键盘快捷 Win+R,打开“运行”,输入 cmd
输入 javac ,回车
![](https://img-blog.csdnimg.cn/20200225171445961.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3UwMTQ3MjAwMjI=,size_16,color_FFFFFF,t_70)
- 确认环境变量
![](https://img-blog.csdnimg.cn/20200225171341702.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3UwMTQ3MjAwMjI=,size_16,color_FFFFFF,t_70)
## 4. 配置 Android Studio
每次在一台新的电脑中安装完 AS 都需要对其进行一些配置,今天总结一下,方便以后换电脑了再配置。
### 4.1 设置代码字体大小和样式
1. command + ,快速弹出 Preferences 框;
2. 点击 Editor --> Font;
3. 修改完后点击 Apply --> OK 。
![a.jpg](https://imgconvert.csdnimg.cn/aHR0cHM6Ly91cGxvYWQtaW1hZ2VzLmppYW5zaHUuaW8vdXBsb2FkX2ltYWdlcy85MTM0ODIyLTkwNDU3NWQ2MzJmNmZlY2EuanBn?x-oss-process=image/format,png)
### 4.2 代码提示不区分大小写
1. command + ,快速弹出 Preferences 框;
2. 点击 Editor --> General --> Code Completion ;
3. 去掉 Match case 勾选;
4. 修改完后点击 Apply --> OK 。
![b.jpg](https://imgconvert.csdnimg.cn/aHR0cHM6Ly91cGxvYWQtaW1hZ2VzLmppYW5zaHUuaW8vdXBsb2FkX2ltYWdlcy85MTM0ODIyLWUzZGRkZTVlOWY4NTk0ZDYuanBn?x-oss-process=image/format,png)
### 4.3 变量命名提示
1. command + ,快速弹出 Preferences 框;
2. 点击 Editor --> Code Style --> Java --> Code Generation ;
3. 设置 Filed 前缀为: m ,Static Filed 前缀为: s;
4. 修改完后点击 Apply --> OK 。
![c.jpg](https://imgconvert.csdnimg.cn/aHR0cHM6Ly91cGxvYWQtaW1hZ2VzLmppYW5zaHUuaW8vdXBsb2FkX2ltYWdlcy85MTM0ODIyLWRkZGNmMDBlMjlkYjVjOGYuanBn?x-oss-process=image/format,png)
### 4.4 设置编码者信息
1. command + ,快速弹出 Preferences 框;
2, 选择 Editor -> File And Code Templates -> Includes -> File Header;
3. 填写自己的模板,勾选 Enable Live Templates;
4. 然后点击 Apply -> OK 应用。
![d.jpg](https://imgconvert.csdnimg.cn/aHR0cHM6Ly91cGxvYWQtaW1hZ2VzLmppYW5zaHUuaW8vdXBsb2FkX2ltYWdlcy85MTM0ODIyLTU1ZGJjYjQyNzdkNDQ4OTEuanBn?x-oss-process=image/format,png)
### 4.5 修改 Logcat 日志的显示颜色
1. command + ,快速弹出 Preferences 框;
2. 选择 Editor --> Color Scheme --> Android Logcat;
3. 去掉 Inherit values from: 勾选,修改相应等级的颜色;
4. 然后点击 Apply -> OK 应用。
Assert #BA68C8
Debug #2196F3
Error #F44336
Info #4CAF50
Verbose #BBBBBB
Warning #FF9800
![e.jpg](https://imgconvert.csdnimg.cn/aHR0cHM6Ly91cGxvYWQtaW1hZ2VzLmppYW5zaHUuaW8vdXBsb2FkX2ltYWdlcy85MTM0ODIyLWY1Y2UwOGM0OTFiMzIyYTguanBn?x-oss-process=image/format,png)
### 4.6 安装常用插件
1. command + ,快速弹出 Preferences 框;
2. 选择 Plugins -> Browse Reposteries;
3. 搜索 Xxxx 插件 ,然后点击 Install;
4. 安装完成后,重启 Android Studio。
* Parcelable 一键完成序列化对象
* GsonFormat 一键将json 转Java Been
* Alibaba Java Coding Guidelines 检查代码是否规范
![g.jpg](https://imgconvert.csdnimg.cn/aHR0cHM6Ly91cGxvYWQtaW1hZ2VzLmppYW5zaHUuaW8vdXBsb2FkX2ltYWdlcy85MTM0ODIyLWU0MzE5ODNhYjdjZWE2ZmQuanBn?x-oss-process=image/format,png)
## Android studio 设置自动导包:
File -->Setting-->Editor-->General-->Auto Import ,进入到该界面后可以看到有 Add unambiguous imports on the fly 选项,勾选此选项即可实现自动导入包。Optimize imports on the fly(for current project)选项,功能是自动删除无用的包,可以看情况勾选啦!
### 4.7 更换主题
使用 [Colors Themes](http://color-themes.com/?view=index) 提供的的主题模版 :
这里提供了很多模版,选择一个你喜欢的下载,下载下来是一个jar 包,导入 Android Studio 就可以使用了。
1. 找到你喜欢的主题模版,点击右下角的下载按钮,进入如下图:
![f.jpg](https://imgconvert.csdnimg.cn/aHR0cHM6Ly91cGxvYWQtaW1hZ2VzLmppYW5zaHUuaW8vdXBsb2FkX2ltYWdlcy85MTM0ODIyLWM0M2ViYjk1MjEzOTdkMGUuanBn?x-oss-process=image/format,png)
2. 下载下来是一个很小的 Jar包,我们直接包jar包导入Android Studio 。在Android Studio 上 点击 File -> Import Settings ,选择中下载的jar 包,来到如下界面:
![image](https://imgconvert.csdnimg.cn/aHR0cHM6Ly91cGxvYWQtaW1hZ2VzLmppYW5zaHUuaW8vdXBsb2FkX2ltYWdlcy8zNTEzOTk1LTg4Yzk5OTBkMGY5ZTVlYzQucG5n?x-oss-process=image/format,png)
3. 如上图,点击确认,会提示重启 Android Studio ,点击 OK 重启 Android Studio 就好了。
[Android Studio 小技巧合集](https://juejin.im/entry/56c1556179bc440054fd4e6b?utm_source=gold-miner&utm_medium=readme&utm_campaign=github)