前言
開發(fā)工具:Android Studio 2.1.2(mac版本)
開發(fā)環(huán)境:OS X EI Capitan 版本 10.11.5
一.常用快捷鍵
網(wǎng)上介紹快捷鍵一堆,我只寫幾個(gè)我自己常用的
Ctrl+R 運(yùn)行APP
Ctrl+Alt(Option)+O 去掉未使用的jar包
Alt(Option)+Command+L 格式化代碼
Ctrl+N 查找類
Ctrl+Shift+N 查找文件
Alt(Option)+Enter 導(dǎo)入缺失的jar包
二.常用插件
先談?wù)勅绾伟惭b插件
良心插件推薦
插件名稱 | 插件功能 |
---|---|
Android ButterKnife Zelezny | butterKnife自動(dòng)生成注解插件,包括holder |
Android Parcelable code generator | Parcelable自動(dòng)生成插件 |
Androd Propery Initializer | findViewById 生成插件 |
GsonFormat | 把json數(shù)據(jù)往粘貼板一貼,自動(dòng)生成Bean有沒有,顯著提高生成力。 |
注解插件ButterKnifey的使用(真的是利器,極大的提高的效率)
三.一些設(shè)置技巧
1.如何設(shè)置代碼正文字體
2.如何設(shè)置主題
安裝一款主題插件,這個(gè)主題我比較喜歡
https://meedamian.com/post/deuglifying-android-studio/?hi
3.關(guān)閉拼寫檢查
4.查看當(dāng)前Gradle的版本
右擊app,顯示包名
5.顯示代碼行數(shù)
6.注釋模板的使用
需求如下:
操作步驟如下:
自定義注釋模板就可以了
參考文檔:http://www.tuicool.com/articles/JNNFrym
7.如何新建一個(gè)空的Activity
8.設(shè)置文件的命名前綴
9.如何將內(nèi)部類,單獨(dú)生成一個(gè)文件
10.如何導(dǎo)入jar包
11.Gradle優(yōu)化
a.加大內(nèi)存
進(jìn)入app包內(nèi)容
根據(jù)自己機(jī)器的配置,自行配置(內(nèi)存越大越好)
-Xms1024m
-Xmx2048m
-XX:MaxPermSize=350m
-XX:ReservedCodeCacheSize=225m
-XX:+UseCompressedOops
b.增加gradle.properties
內(nèi)容如下:
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Settings specified in this file will override any Gradle settings
# configured through the IDE.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# The Gradle daemon aims to improve the startup and execution time of Gradle.
# When set to true the Gradle daemon is to run the build.
# TODO: disable daemon on CI, since builds should be clean and reliable on servers
org.gradle.daemon=true
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m - XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
org.gradle.parallel=true
# Enables new incubating mode that makes Gradle selective when configuring projects.
# Only relevant projects are configured which results in faster builds for large multi-projects.
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:configuration_on_demand
org.gradle.configureondemand=true
12.svn提交代碼,忽略文件配置
1、.idea文件夾
2、.gradle文件夾
3、所有的build文件夾
4、所有的.iml文件
5、local.properties文件。
提交方法:
點(diǎn)擊右側(cè)的“+”進(jìn)行添加,“-”刪除;Android Studio創(chuàng)建的Android項(xiàng)目一般需要忽略.idea文件夾、.gradle文件夾、所有的build文件夾、所有的.iml文件及l(fā)ocal.properties文件。
忽略完文件后,我們進(jìn)行項(xiàng)目同SVN的關(guān)聯(lián),選擇VCS->Import into Version Control->Share Project(Subversion);這里說明一點(diǎn),在Import into Version Control下有Import into Subversion和Share Project(Subversion)兩個(gè)選項(xiàng)【在studio 1.3已經(jīng)沒有第二個(gè)選項(xiàng)了只有Share Project on GitHup】:
Import into Subversion 第一個(gè)是直接將項(xiàng)目導(dǎo)入到SVN服務(wù)器上,但是這樣做本地的項(xiàng)目同SVN服務(wù)器沒有建立起關(guān)聯(lián),在導(dǎo)入后項(xiàng)目所有的文件都會(huì)變成紅色,而且在要提交到SVN服務(wù)器時(shí)會(huì)提示項(xiàng)目不是SVN下的工作副本;
Share Project(Subversion) 第二個(gè)是將Android Studio當(dāng)前項(xiàng)目同SVN服務(wù)器關(guān)聯(lián)起來,但是并沒有將項(xiàng)目導(dǎo)入到SVN服務(wù)器上,需要在完成建立連接后再次提交項(xiàng)目到SVN服務(wù)器。
13.配置備份與導(dǎo)入
14.關(guān)鍵字鼠標(biāo)懸停提示
15.如何在項(xiàng)目中新建個(gè)assets目錄
參考資料
Android Studio提示與技巧(官方文檔翻譯)
http://www.open-open.com/lib/view/open1462930766027.html
Android Studio 進(jìn)階配置
http://www.2cto.com/kf/201605/504903.html
Gradle的使用
https://services.gradle.org/distributions
Android Studio模板文件的新建
http://www.2cto.com/kf/201604/502599.html
加速Gradle編譯
http://www.jcodecraeer.com/a/anzhuokaifa/Android_Studio/2015/0324/2637.html
常用功能介紹
http://www.androidchina.net/3601.html
Android Studio錯(cuò)誤代碼不提示BUG(省電模式說明)
http://m.blog.csdn.net/article/details?id=48708459
Android Studio中文社區(qū)
http://forum.android-studio.org/forum.php?mod=forumdisplay&fid=40
安裝視頻教程
http://www.jikexueyuan.com/course/396.html
使用視頻教程(英文版)
http://ask.android-studio.org/?/explore/category-video