您的位置:首页 > 移动开发 > Android开发

Android studio优化教程

2016-12-10 10:15 225 查看

AS安装教程:

【新提醒】Windows环境下Android Studio v1.0安装教程-黑马程序员IT技术论坛 - 黑马程序员快速入学必看论坛

在讲解7需要一提的是:



PS:jdk需要1.7以上才行,否则可能会报错,说jdk找不到,jdk安装教程:eclipse安装与使用教程_百度经验

AS插件精品:

[1] ButterKnife Zelezny

强大的View绑定和Click事件处理,轻松处理Adapter的viewHolder的绑定问题

[2] Key Promoter

[3] GsonFormat 根据json生成JavaBean,需要Gson的支持

[4] Android Studio Prettify 生成findViewById

在setContentView,或者在view上alt+insert,名字什么的没法自己指定

[5] Parcelable 被用作封装数据的容器,封装后的数据可以通过Intent或IPC传递

[6] CodeGlance 代码预览窗口(代码窗口的右侧显示)

[7] LayoutCreator 一键findViewById

[8] Android Posttfix Completion (常用的后缀补齐),Postfix completion介绍

[9] 30多个Android开发者超赞的工具

[10] FindBugs

[11] 回顾下今年使用过的好用的插件、工具等

AS优化教程:

优化Android Studio/Gradle构建-黑马程序员IT技术论坛 - 黑马程序员快速入学必看论坛

开启gradle单独的守护进程

1.在C:\Users\yueyue.gradle路径下新建一个gradle.properties.txt文件



2.把下面代码复制到gradle.properties文件进行优化:

# 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


同时上面的这些参数也可以配置到前面的用户目录下的gradle.properties文件里,那样就不是针对一个项目生效,而是针对所有项目生效。

上面的配置文件主要就是做, 增大gradle运行的java虚拟机的大小,让gradle在编译的时候使用独立进程,让gradle可以平行的运行。

申请大内存

[1] 在D:\Program Files (x86)\Java\Android\android-studio\bin文件夹(路径为电脑安装Android studio路径)下找到配置文件

PS:你想用32位的Android studio就配置32文件,64的话就配置64位文件



[2] 打开studio64.exe.vmoptions,使用文本编辑器打开,找到起始两行,修改最小值和最大值,建议为

-Xms256m

-Xmx2048m



优化编译

file->setting->compile

勾选除第二项之外的其他选项,并在VM options里填入:

-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8



PS-Xmx跟XX的值对应申请大内存修改的值!!!

经过测试,编译速度有很大提升,比较大的项目从之前的5-8分钟可以减少到1-2分钟。

注意事项:

在setting里面设置的gradle选项里,如果勾选了offline work(离线工作),那么编译会快很多,但是在加载第三方的时候会有问题,所以不建议勾选



优化教程连接:

[1] 14条Android Studio常用的的配置 - wk843620202的专栏 - 博客频道 - CSDN.NET

[2] android studio 高级设置–驼峰选择,命名前缀,快速导包,Log 颜色等等 - binbinyang博客 - 博客频道 - CSDN.NET

[3] Android Studio SVN 使用方法(入门) - CSDN博客
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息