First of all, upgrade your Android Studio to 2.1.0 and use android gradle plugin version to 2.1.0. It will help you open following features as default. You can see more information in here.
- New features in 2.1.0
- incremental Java compilation
- dexing-in-process
- New features in 2.0.0
- incremental builds
Then we can start:
1.Enable offline mode in your Android Studio.
2.Configure your gradle.properties file, normally I will put it under project root folder. (I don't have one, how to create it?)
Add following statements in your gradle.properties
# 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=-Xms512m -Xmx1024m -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
org.gradle.workers.max=4
- Parallel mode would't help you too much, because most projects only contain dependency module.
- You will ask where's the daemon mode statement? People on the internet told you should use gradle daemon. I agree with them, but:
-
Gradle team suggest not use gradle daemon in CI job, so I didn't put it in gradle.properties file, because gradle.properties will also impact your CI job as default. You can see more information in here.
-
Gradle daemon will enable when build in Android Studio.
-
If you need to build project in command line of your local machine, please enable it manually by adding "--daemon" at the end of your gradle command, like following command.
gradle assembleDebug --daemon # when you want to stop it, use "gradle --stop"
-
That's all. Thanks for reading!
My personal project commit for this
网友评论