This page is obsolete. You're being redirected to developer.android.com/studio/build/build-cache.htmlUpdate for Android Studio 2.3 Canary:
IntroductionAndroid Studio 2.2 Beta 3 introduces a new build cache feature that can speed up build times for clean builds by storing and reusing files/directories that were created in previous builds of the same or different Android project.
The build cache is meant to be used across all Android projects. The developer can enable/disable the build cache and specify its location in the gradle.properties file. Currently, the build cache contains only pre-dexed libraries; in the future, we will use it for caching other types of files as well. Note that the build cache works independently of Gradle’s cache management (e.g., reporting up-to-date statuses). When a task is executed, whether the build cache is used or not during its execution will be unknown to Gradle (i.e., even when the cache is hit, Gradle’s profile report will not show the task as up-to-date). However, you should expect to get faster build times when the build cache is used.
Although there are currently no known issues, we would like to provide the community more time to provide feedback on it. This feature is currently considered to be experimental and is disabled by default (update: this feature enabled by default starting with Android Studio 2.3 Canary 1). With your feedback, we are aiming to graduate it to stable and enable it by default in Android Studio 2.3 or 2.4. How to use the Build CacheStep 0Ensure that android.dexOptions.preDexLibraries is either not set or set to true; otherwise the libraries will not be pre-dexed and therefore the build cache will not be used.Step 1In an Android project, open the gradle.properties file and add the following parameters:
Step 2Build your Android project (on the terminal, type ./gradlew assemble) and check the following locations to see whether the build cache took effect.
Note: If you are using Multi-dex with minSdk >= 21, the dexed files will be stored directly into the <project-dir/module-dir>/build/intermediates/transforms/dex directory without being stored in <project-dir/module-dir>/build/intermediates/pre-dexed. Cleaning the Build CacheTo clean the build cache, you can navigate to the build cache directory and delete all the files in that directory. The build cache directory is either located at the path specified by the android.buildCacheDir property in your gradle.properties file, or it is located at <user-home-directory>/.android/build-cache by default. Update: starting with Android Studio 2.3 Canary 1, there is a now a Gradle task called cleanBuildCache that you can use to more conveniently clean the build cache. You can use it by typing the following in your terminal: ./gradlew cleanBuildCache Feedback We encourage you to try this feature and to see how it's working for you. Please file a bug to us if you find any issues or if you have other feedback about this feature for us. Thanks! |
Technical docs >