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

How does android.enableBuildCache=true functions in new Android Studio 2.2?

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

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

此 link 显示了所有详细信息: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.