AndroidStudio基本配置
2017-09-04 01:23
357 查看
AndroidStudio基本配置
本文是对Android开发者网站的相关文章总结1.配置文件
Android Studio 通过 Help 菜单提供对两个配置文件的访问:studio.vmoptions:自定义 Studio Java 虚拟机 (JVM) 的选项,如堆内存和缓存大小。
idea.properties:自定义 Android Studio 的属性,如插件文件夹路径或最大支持文件大小。
2.配置文件位置
Windows:%USERPROFILE%.CONFIGURATION_FOLDER/Mac:~/Library/Preferences/CONFIGURATION_FOLDER/
Linux:~/.CONFIGURATION_FOLDER/
3.自定义Vm选项
通过 studio.vmoptions 文件,您可以自定义适用于 Android Studio 的 JVM 的选项。最常用的调节选项是最大堆内存,初始堆内存、缓存大小和 Java 垃圾回收开关。要新建 studio.vmoptions 文件或打开现有文件,请执行以下步骤:
1.点击 Help > Edit Custom VM Options。如果您之前从未编辑过适用于 Android Studio 的 VM 选项,IDE 将提示您新建一个 studio.vmoptions 文件。点击 Yes 创建文件。
2.此时 studio.vmoptions 文件将在 Android Studio 的编辑器窗口中打开。编辑文件以添加您自己的自定义 VM 选项。如需可自定义 JVM 选项的完整列表,请参阅 Oracle 的 Java HotSpot VM 选项页。
3.您创建的 studio.vmoptions 文件将添加至默认 studio.vmoptions 文件,后者位于 Android Studio 安装文件夹内的 bin/ 目录中。
4.设置最大堆内存
点击 Help > Edit Custom VM Options 以打开您的 studio.vmoptions 文件。向 studio.vmoptions 文件添加一个行,使用语法 -XmxheapSize 设置最大堆内存。您选择的大小应该基于项目大小以及机器上的可用 RAM。作为基准,如果您有 4GB 以上的 RAM 和中等大小的项目,则应该将最大堆内存设置为 2GB 或更高。以下行可将最大堆内存设置为 2GB:
-Xmx2g
5.自定义 IDE 属性
要新建 idea.properties 文件或打开现有文件,请执行以下步骤:1.点击 Help > Edit Custom Properties。如果您之前从未编辑过 IDE 属性,Android Studio 将提示您新建一个 idea.properties 文件。点击 Yes 创建文件。
2.此时 idea.properties 文件将在 Android Studio 的编辑器窗口中打开。编辑文件以添加您自己的自定义 IDE 属性。
idea.properties文件如下所示:
#--------------------------------------------------------------------- # Uncomment this option if you want to customize path to user installed plugins folder. Make sure # you're using forward slashes. #--------------------------------------------------------------------- # idea.plugins.path=${idea.config.path}/plugins #--------------------------------------------------------------------- # Maximum file size (kilobytes) IDE should provide code assistance for. # The larger file is the slower its editor works and higher overall system memory requirements are # if code assistance is enabled. Remove this property or set to very large number if you need # code assistance for any files available regardless their size. #--------------------------------------------------------------------- idea.max.intellisense.filesize=2500 #--------------------------------------------------------------------- # This option controls console cyclic buffer: keeps the console output size not higher than the # specified buffer size (Kb). Older lines are deleted. In order to disable cycle buffer use # idea.cycle.buffer.size=disabled #--------------------------------------------------------------------- idea.cycle.buffer.size=1024 #--------------------------------------------------------------------- # Configure if a special launcher should be used when running processes from within IDE. # Using Launcher enables "soft exit" and "thread dump" features #--------------------------------------------------------------------- idea.no.launcher=false #--------------------------------------------------------------------- # To avoid too long classpath #--------------------------------------------------------------------- idea.dynamic.classpath=false #--------------------------------------------------------------------- # There are two possible values of idea.popup.weight property: "heavy" and "medium". # If you have WM configured as "Focus follows mouse with Auto Raise" then you have to # set this property to "medium". It prevents problems with popup menus on some # configurations. #--------------------------------------------------------------------- idea.popup.weight=heavy #--------------------------------------------------------------------- # Use default anti-aliasing in system, i.e. override value of # "Settings|Editor|Appearance|Use anti-aliased font" option. May be useful when using Windows # Remote Desktop Connection for instance. #--------------------------------------------------------------------- idea.use.default.antialiasing.in.editor=false #--------------------------------------------------------------------- # Disabling this property may lead to visual glitches like blinking and fail to repaint # on certain display adapter cards. #--------------------------------------------------------------------- sun.java2d.noddraw=true #--------------------------------------------------------------------- # Removing this property may lead to editor performance degradation under Windows. #--------------------------------------------------------------------- sun.java2d.d3d=false #--------------------------------------------------------------------- # Workaround for slow scrolling in JDK6 #--------------------------------------------------------------------- swing.bufferPerWindow=false #--------------------------------------------------------------------- # Removing this property may lead to editor performance degradation under X Window. #--------------------------------------------------------------------- sun.java2d.pmoffscreen=false #--------------------------------------------------------------------- # Workaround to avoid long hangs while accessing clipboard under Mac OS X. #--------------------------------------------------------------------- # ide.mac.useNativeClipboard=True #--------------------------------------------------------------------- # Maximum size (kilobytes) IDEA will load for showing past file contents - # in Show Diff or when calculating Digest Diff #--------------------------------------------------------------------- # idea.max.vcs.loaded.size.kb=20480
6.低内存机器设置
1.启用节能模式:启用节能模式会关闭一系列消耗大量内存和电池的后台操作,包括错误突出显示和动态检查、自动弹出式代码完成和自动增量式后台编译。要打开节能模式,请点击 File > Power Save Mode。2.停用不必要的 lint 检查:要更改 Android Studio 在您的代码上运行的 lint 检查,请继续执行以下操作:
点击 File > Settings(在 Mac 中,点击 Android Studio > Preferences)以打开 Settings 对话框。
在左侧窗格中,展开 Editor 部分并点击 Inspections。
点击复选框以选择或取消选择项目适用的 lint 检查。
点击 Apply 或 OK 以保存所做的更改。
3.不要启用并行编译:Android Studio 可以并行编译独立模块,但如果您具有低内存系统,则不应启用此功能。要选中此设置,请继续执行以下操作:
点击 File > Settings(在 Mac 中,点击 Android Studio > Preferences)以打开 Settings 对话框。
在左侧窗格中,展开 Build, Execution, Deployment,然后点击 Compiler。
确保 Compile independent modules in parallel 选项未选中。
如果您进行了更改,请点击 Apply 或 OK 以使更改生效。
7.设置 JDK 版本
最新 OpenJDK 的副本与 Android Studio 2.2 和更高版本捆绑提供,这是我们建议用于 Android 项目的 JDK 版本。要使用捆绑的 JDK,请继续执行以下操作:在 Android Studio 中打开您的项目,然后在菜单栏中选择 File > Project Structure。
在 SDK Location 页面中的 JDK location 下方,选中 Use embedded JDK 复选框。
点击 OK。
默认情况下,用于编译项目的 Java 语言版本基于项目的 compileSdkVersion (因为不同 Android 版本支持不同版本的 Java)。如有必要,您可以通过将以下 CompileOptions {} 代码块添加到 build.gradle 文件来替换此默认 Java 版本:
android { compileOptions { sourceCompatibility JavaVersion.VERSION_1_6 targetCompatibility JavaVersion.VERSION_1_6 } }
引用:
https://developer.android.com/
相关文章推荐
- AndroidStudio 基本混淆配置
- AndroidStudio的基本配置和使用
- 从Eclipse到AndroidStudio(四)Gradle基本配置
- 从Eclipse到AndroidStudio(四)Gradle基本配置
- AndroidStudio的基本配置
- OSPF 基本配置
- 一个spring 基本知识的微博(怎么加载多个xml、多个property文件、aop配置、监视器)
- yum配置(源配置-光驱,ftp服务器;基本用法)
- iOS开发-开发百度地图1-iOS SDK 3.0.0-基本地图的配置及实现
- linux下的基本网络配置
- lighttpd基本配置
- mongodb 配置 基本命令
- HBase的基本配置要点
- Java语言基础{Java_se(01)}-搭建Java开发环境-环境变量(环境配置)-Java的基本语法-Java的三大注释-关键字和保留字-Java中的语言分隔符
- spring配置文件的基本写法
- 使用VUE-CLI构建一个项目基本的配置
- My Vim 基本配置 (stl tags 自动提示功能)
- 安装CentOS后的基本配置
- spring学习笔记2——基本Bean配置