android - android.enableBuildCache=true 在新的 Android Studio 2.2 中如何运行?

标签 android android-gradle-plugin build.gradle android-studio-2.2

我最近迁移到新的 Android Studio 2.2 以及我还遇到的许多其他功能 android.enableBuildCache=true 以减少构建时间。

我的问题是,这如何帮助我的构建速度更快以及到底缓存了什么?因为我实际上注意到初始构建时间增加了,这让我怀疑我是否应该使用它。如果有人可以向我解释内部功能以及究竟缓存了什么以及在什么条件下,那么也许我将能够微调此缓存并加速我的构建。

最佳答案

此链接显示所有详细信息:http://tools.android.com/tech-docs/build-cache

这里有一些相关的部分:

... build cache feature that can speed up build times (including full builds, incremental builds, and instant run) by storing and reusing files/directories that were created in previous builds of the same or different Android project.

Currently, the build cache contains only pre-dexed libraries; in the future, we will use it for caching other types of files as well.

当你的构建时间增加时,那么可能

  • 我想这对于激活缓存后的第一次构建来说可能是正常的
  • 这是这个实验性功能的错误:在这种情况下,请 file a bug
  • 根本没有使用缓存:

    Step 0
    Ensure 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 1
    android.enableBuildCache=true

    Step 2
    Build your Android project and check the following locations to see whether the build cache took effect. By default the cache-dir is /.android/build-cache. The final pre-dexed files are stored in /build/intermediates/pre-dexed/debug and /build/intermediates/pre-dexed/release. You need to run the command line to see the “pre-dexed” directory; if you click the “Run” button from the Android Studio menu, you will not see this directory as it will be deleted.

    Note: If you are using Multi-dex with minSdk >= 21, the dexed files will be stored directly into the /build/intermediates/transforms/dex directory without being stored in /build/intermediates/pre-dexed.

关于android - android.enableBuildCache=true 在新的 Android Studio 2.2 中如何运行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39692702/

相关文章:

android - 当我的 Activity 发生变化或破坏时,如何阻止 ASyncTask 崩溃?

安卓网络地址

java - Android - 如何通过文件名获取文件?

android - android sqlite数据库中rawquery和execSQL的区别

android - Firebase身份验证和数据库链接

安卓工作室 : Gradle Product Flavors: Define custom properties

maven - 错误:The 'java' plugin has been applied,但与Android插件不兼容

android - 如何为所有android studio项目设置默认库

gradle - 如何在distTar中为gradle生成的脚本添加语句?

java - Gradle无法解析标记为 'LATEST'的依赖项的依赖项