加快android studio 编译速度

加快android studio 编译速度

工程build一次太慢 经过各种搜索 整合以下 仅供参考
1、在下列目录中新建 gradle.properties 文件

/home//.gradle/ (Linux)
/Users//.gradle/ (Mac)
C:\Users\.gradle (Windows)
在文件中添加
org.gradle.daemon=true

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

同样也可以将global properties 设置如上 所以的工程都会依照这个设置

3、打开file-setting-build-compiler进行如下设置
这里写图片描述
打开file-setting-build-buildTool进行如下设置
这里写图片描述
此处设置为offline 并且 应用本地gradle 加快编译速度

4、打开file-Project Structure
这里写图片描述
设置gradle的version

5、在你的app gradle下 添加如下

dexOptions {
        incremental true
        javaMaxHeapSize "4g"
        preDexLibraries = false
}

6、除此之外 由于国内访问国外服务器较慢 造成as又卡又慢
所以尽量使用jar arr 等方式 减少直接compile

*.jar:只包含了class文件与清单文件,不包含资源文件,如图片等所有res中的文件。
*.aar:包含所有资源,class以及res资源文件全部包含
如果你只是一个简单的类库那么使用生成的*.jar文件即可;
如果你的是一个UI库,包含一些自己写的控件布局文件以及字体等资源文件那么就只能使用*.aar文件。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值