• Stars
    star
    440
  • Rank 99,050 (Top 2 %)
  • Language
    Groovy
  • License
    Apache License 2.0
  • Created about 7 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Gradle plugin that fixes Android build caching problems.

This repository is maintained by the Gradle Enterprise Solutions team, as one of several publicly available repositories:

Android Cache Fix Gradle Plugin

Verify Build Plugin Portal Revved up by Gradle Enterprise

Some Android plugin versions have issues with Gradle's build cache feature. When applied to an Android project this plugin applies workarounds for these issues based on the Android plugin and Gradle versions. For other versions, please see older versions.

  • Supported Gradle versions: 7.0+
  • Supported Android Gradle Plugin versions: 7.0.4, 7.1.3, 7.2.2, 7.3.1, 7.4.2, 8.0.2, 8.1.0 and 8.2.0-alpha14
  • Supported Kotlin versions: 1.7.0+

We only test against the latest patch versions of each minor version of Android Gradle Plugin. This means that although it may work perfectly well with an older patch version (say 7.0.1), we do not test against these older patch versions, so the latest patch version is the only version from that minor release that we technically support.

The Android cache fix plugin is compatible with the Gradle Configuration Cache when used in conjunction with Android Gradle Plugin 4.2.0 and above. Using the configuration cache with earlier versions of the Android Gradle Plugin is not supported.

Should I use this?

Take a look at the list of issues especially unresolved issues. If any of these apply to your project, you can use this plugin to solve them.

How can I discover issues?

You can discover issues by using the task input comparison tool in Gradle Enterprise. More information about how to diagnose cache misses here. You can compare the inputs of a build that seeds the build cache - typically CI - with a build that consumes from the build cache like a local developer build. If you discover an issue related to the Android Gradle Plugin, please file an issue in the Android Bug Tracker. You can also file an issue here and we can see if a workaround is possible.

Applying the plugin

This plugin should be applied anywhere the com.android.application or com.android.library plugins are applied. We recommend adding the plugin to your project's conventions plugin.

Kotlin
// in build.grade.kts for convention plugin build
dependencies {
  // ...
  implementation("org.gradle.android.cache-fix:org.gradle.android.cache-fix.gradle.plugin:2.7.2")
  // ...
}

// in com.myconventions.build.gradle.kts
plugins {
    id("com.android.application") // or "com.android.library"
  // Add this next line to your existing convention plugin.
    id("org.gradle.android.cache-fix")
}
Groovy
// in build.grade for convention plugin build
dependencies {
    // ...
    implementation("org.gradle.android.cache-fix:org.gradle.android.cache-fix.gradle.plugin:2.7.2")
    // ...
}

// in com.myconventions.build.gradle
plugins {
    id 'com.android.application' // or 'com.android.library'
    // Add this next line to your existing convention plugin.
    id 'org.gradle.android.cache-fix'
}

If you are not using convention plugins and would like a quick way of testing the plugin you can alternatively place it in the root project's build.gradle (change '2.7.2' to the latest version of the cache fix plugin here). We discourage this approach because it uses cross project configuration.

Kotlin
plugins {
    id("org.gradle.android.cache-fix") version "2.7.2" apply false
}

subprojects {
    plugins.withType<com.android.build.gradle.api.AndroidBasePlugin>() {
        apply(plugin = "org.gradle.android.cache-fix")
    }
}
Groovy
plugins {
    id "org.gradle.android.cache-fix" version "2.7.2" apply false
}

subprojects {
    plugins.withType(com.android.build.gradle.api.AndroidBasePlugin) {
        project.apply plugin: "org.gradle.android.cache-fix"
    }
}

Note that if you are currently exporting schemas with the Room annotation processor, you will need to change how you specify the output directory according to the instructions here.

List of issues

You can take a look at the list of issues that the plugin fixes by looking at the classes in org.gradle.android.workarounds. It contains a number of Workaround implementations annotated with @AndroidIssue. The Javadoc has a short description of the problem, and the annotation gives information about when the problem was introduced, what is the first version of the Android plugin that fixes it, and there's a link to the issue on Android's issue tracker:

/**
 * Fix {@link org.gradle.api.tasks.compile.CompileOptions#getBootClasspath()} introducing relocatability problems for {@link AndroidJavaCompile}.
 */
@AndroidIssue(introducedIn = "3.0.0", fixedIn = "3.1.0-alpha06", link = "https://issuetracker.google.com/issues/68392933")
static class AndroidJavaCompile_BootClasspath_Workaround implements Workaround {
    // ...
}

Unresolved Issues

Please vote for the linked issues if you are experiencing them in your project.

Fixed by the Android Cache Fix plugin, but unresolved in any current or upcoming preview release of the Android Gradle Plugin:

Not fixed by the Android Cache Fix plugin since it has no workaround:

Not fixed by the Android Cache Fix plugin since it has no workaround but is fixed in Android Gradle Plugin 8.0.0 or newer:

Implementation Notes

RoomSchemaLocationWorkaround

Most of the workarounds in this plugin should apply to your project without any changes. However, one workaround requires some extra configuration. The Room schema location workaround allows you to specify an output directory for Room schema exports without breaking caching for your Java and/or Kapt tasks where the annotation processor has been configured. There are various issues with how this annotation processor works (see https://issuetracker.google.com/issues/132245929 and https://issuetracker.google.com/issues/139438151) which this workaround attempts to mitigate. However, in order to do so in a manageable way, it imposes some restrictions:

  • The schema export directory must be configured via the "room" project extension instead of as an explicit annotation processor argument. If an explicit annotation processor argument is provided, an exception will be thrown, instructing the user to configure it via the extension:
Kotlin
room {
    schemaLocationDir.set(file("roomSchemas"))
}
Groovy
room {
    schemaLocationDir = file("roomSchemas")
}
  • There can only be a single schema export directory for the project - you cannot configure variant-specific export directories. Schemas exported from different variants will be merged in the directory specified in the "room" extension.

Ksp

Since version 2.7.0, RoomSchemaLocationWorkaround supports Kotlin Symbol Processing(Ksp). Like Kapt, applying the Room processor with Ksp was causing cache misses. The workaround allows you to specify an output directory for Room schema exports. The schema export directory must be configured via the "room" project extension instead of the Ksp configuration:

Kotlin
room {
    schemaLocationDir.set(file("roomSchemas"))
}
Groovy
room {
    schemaLocationDir = file("roomSchemas")
}

Supported Ksp versions: 1.7.20-1.0.8+

MergeNativeLibs, StripDebugSymbols, MergeJavaResources, MergeSourceSetFolders, BundleLibraryClassesJar, DataBindingMergeDependencyArtifacts, LibraryJniLibs and ZipMerging Workarounds

It has been observed that caching the MergeNativeLibsTask, StripDebugSymbols, MergeSourceSetFolders, BundleLibraryClassesJar, DataBindingMergeDependencyArtifacts, LibraryJniLibs and ZipMergingTask tasks rarely provide any significant positive avoidance savings. In fact, they frequently provide negative savings, especially when fetched from a remote cache node. As such, these workarounds disable caching for these tasks.

Older Android Gradle Plugin Versions

Use Android Cache Fix Plugin 2.4.6 when using an older Android Gradle Plugin version.

  • Supported Gradle versions: 5.4.1+
  • Supported Android Gradle Plugin versions: 3.5.4, 3.6.4, 4.0.1, 4.1.3, 4.2.2

Older Kotlin Gradle Plugin Versions

Use Android Cache Fix Plugin 2.6.0 when using an older Kotlin Gradle Plugin version.

  • Supported Kotlin versions: [1.3.72-1.5.32]

License

The Android Cache Fix Gradle plugin is open-source software released under the Apache 2.0 License.

More Repositories

1

gradle

Adaptable, fast automation for all
Groovy
16,800
star
2

kotlin-dsl-samples

Samples builds using the Gradle Kotlin DSL
Kotlin
3,706
star
3

gradle-profiler

A tool for gathering profiling and benchmarking information for Gradle builds
Java
1,279
star
4

gradle-completion

Gradle tab completion for bash and zsh
Shell
966
star
5

gradle-build-action

Execute your Gradle build and trigger dependency submission
672
star
6

wrapper-validation-action

Gradle Wrapper Validation Action
256
star
7

oreilly-gradle-book-examples

Java
249
star
8

test-retry-gradle-plugin

Gradle plugin to retry tests that have failed to mitigate test flakiness.
Groovy
219
star
9

native-samples

Samples of modern build automation for native languages with Gradle
Java
153
star
10

actions

A collection of GitHub Actions to accelerate your Gradle Builds on GitHub
TypeScript
147
star
11

gradle-build-scan-quickstart

An example project to experience the Build Scanยฎ service of Gradle Enterprise with Gradle builds.
Kotlin
132
star
12

foojay-toolchains

Java Toolchain Resolve Plugin based on the foojay DiscoAPI
Kotlin
120
star
13

native-platform

Java bindings for various native APIs
Java
116
star
14

declarative-gradle

Declarative Gradle is a project targeting better isolation of concern and expressing any build in a clear and understandable way
Java
110
star
15

gradle-native

The home of Gradle's support for natively compiled languages
92
star
16

build-tool-training-exercises

Exercises for live gradle.com/training sessions
Java
90
star
17

gradle-enterprise-build-validation-scripts

Executable scripts to assist in validating that your Gradle and Maven builds are in an optimal state in terms of maximizing work avoidance when using Develocity.
Shell
86
star
18

github-dependency-graph-gradle-plugin

Gradle Plugin for Extracting Dependency Information to send to GitHub
Groovy
81
star
19

develocity-build-config-samples

Code samples that demonstrate how to customize your Develocity build configuration using Gradle, Maven, Bazel or sbt
Java
68
star
20

playframework

Gradle Play Support
Java
47
star
21

guides

The Gradle Guides at https://guides.gradle.org.
Java
47
star
22

wrapper-upgrade-gradle-plugin

Gradle plugin that detects and updates Gradle and Maven wrappers to the latest Gradle and Maven version.
Java
43
star
23

gradle-site-plugin

Kotlin
43
star
24

build-tool-roadmap

Gradle Build Tool roadmap
41
star
25

common-custom-user-data-gradle-plugin

Gradle plugin that enhances published build scans by adding a set of tags, links and custom values that have proven to be useful for many projects building with Develocity.
Java
41
star
26

kotlin-dsl-docs

Generates Kotlin DSL API reference
Kotlin
38
star
27

gradle-talks

A javascript based custom slide and build framework for presentations. Many of the Gradle engineers have been using this for their presentations. Those presentations are part of this repo and can be found in the talks directory.
Ruby
35
star
28

exemplar

Discover and verify code samples and services
Java
34
star
29

gradle2kts

Gradle Groovy to Gradle Kotlin conversion tool - discontinued spike
Kotlin
34
star
30

gradle-checksum

A Gradle plugin for creating checksums for files in your build.
Groovy
31
star
31

kotlin-dsl-conventions

Gradle Kotlin DSL conventional plugins
Kotlin
26
star
32

maven-build-scan-quickstart

An example project to experience the Build Scanยฎ service of Develocity with Maven builds.
Java
20
star
33

bazel-comparison

20
star
34

develocity-oss-projects

19
star
35

gradle-distributions

Repository for Gradle Build Tool distributions downloads
17
star
36

performance-comparisons

A set of synthetic projects used to benchmark Gradle against other build tools
16
star
37

community

Gradle Community content and Gradle Cookbook. Open for Contributions
HTML
16
star
38

gradle-java-modules

A (former) place for experimenting with Java 9's module system. Gradle officially supports Java Modules since version 6.4
Java
16
star
39

gcc2speedscope

Space usage analysis for the Gradle configuration cache via speedscope
Kotlin
15
star
40

cc-hackathon-2022

Configuration Cache Hackathon 2022
15
star
41

.github

Maintains all of the default policies for the Gradle organization
14
star
42

perf-enterprise-large

A large Java based build to use when benchmarking and profiling Gradle
Groovy
14
star
43

gradle-enterprise-export-api-samples

A repository of samples that demonstrate how to use the Gradle Enterprise Export API.
14
star
44

gradle-jdocbook

A Gradle plugin for jdocbook
Groovy
13
star
45

cucumber-companion

Maven & Gradle plugins providing convenient support for running Cucumber test directly from Maven/Gradle
Groovy
13
star
46

multi-project-composite-gradle-plugins-builds

Multi-project build using composite Gradle plugins
Kotlin
12
star
47

develocity-api-samples

A repository of samples that demonstrate how to use the Develocity API.
Java
12
star
48

webinar-getting-started-with-the-gradle-kotlin-dsl

Webinar - Getting Started with the Kotlin DSL
Kotlin
12
star
49

plugin-portal-requests

Gradle Plugin Portal issues and requests.
12
star
50

speed-challenge

Instructions and overview for the Gradle and Maven Speed Challenge event
11
star
51

imaginate

Using the Kotlin language for production, test and build makes it easier for everyone to work with your software code base. Letโ€™s go 100% Kotlin!
Kotlin
11
star
52

continuous-delivery-jump-start

Sample application used for training "Continuous Delivery Jump Start"
Java
11
star
53

santa-tracker-performance

Performance tests for Santa Tracker Android project
Shell
10
star
54

perf-android-large-2

Another large Android build for performance experiments
10
star
55

build-analysis-demo

Build data analysis applications
Kotlin
10
star
56

gradle-issue-reproducer

Template repository for providing Gradle issue reproducers
10
star
57

gradle-benchmark-base

Base scenarios for Gradle Profiler to benchmark Gradle builds
9
star
58

gradle-org-conventions-plugin

Java
9
star
59

gradle-hello-world-plugin

Groovy
9
star
60

gradle-profiler-plugin

Java
9
star
61

develocity-testing-annotations

Common annotations for Develocity and Test Retry
Java
9
star
62

tooling-commons

A small layer on top of the Gradle Tooling API that provides the Tooling Client and other convenience useful for IDE integration.
Java
9
star
63

gradle-client

Desktop application acting as a Gradle Tooling API client
Kotlin
9
star
64

configuration-cache-report

Kotlin
8
star
65

jfr-polyfill

A polyfill for JDK Flight Recorder (JFR) to avoid errors on JDKs that don't support JFR yet
Java
8
star
66

common-custom-user-data-maven-extension

Maven extension that enhances published build scans by adding a set of tags, links and custom values that have proven to be useful for many projects building with Develocity.
Java
8
star
67

develocity-gitlab-templates

GitLab CI/CD templates to automatically connect Gradle/Maven builds to Develocity
Shell
7
star
68

bt-dev-prod-data-collector

Data collector for Gradle Build Tool Developer productivity metrics
Kotlin
7
star
69

gradle-hazelcast-plugin

Groovy
6
star
70

source-resolution-demo

Java
6
star
71

gradle-enterprise-build-optimization-experiments

Self-guiding experiments to optimize the performance of your Gradle and Maven builds with Gradle Enterprise.
6
star
72

gradle-plugin-analyzer

Analyzes the bytecode of Gradle plugins
Java
6
star
73

integrations

A repository for Gradle Integrations and the related knowledge base
6
star
74

gradle-rules-configuration-workshop

6
star
75

gradle-project-templates

Learning day experiment: project init templates for Gradle
Java
5
star
76

greeting-plugin-example

Java
5
star
77

gradle-dependency-constrain

Java
5
star
78

maven-build-cache-unstable-inputs-samples

An example project containing a build with unstable inputs
Java
5
star
79

dpeuni-gradle-intro-devs-init

Hands-on exercise for DPE University
5
star
80

develocity-actions

Shared Github Actions
TypeScript
4
star
81

develocity-bamboo-plugin

Develocity plugin for Bamboo
Java
4
star
82

stable-plugins-dsl

Getting the plugins {} DSL block out of incubation
Java
4
star
83

perf-native-large

A Place to Profile Particularly Prickly Projects
C
4
star
84

backend-code-project

A scaffold for the Develocity Backend Engineer code project assignment.
Java
3
star
85

ide-smoke-tests

Java
3
star
86

gradle-all

A composite build that includes all the pieces of Gradle
Kotlin
3
star
87

ge-export

Java
3
star
88

webinar-dep-mgmt-part-1

Kotlin
3
star
89

gradle-to-trace-converter

Kotlin
3
star
90

provider-api-migration-testbed

A testbed to try out mitigation strategies for the provider API migration
Kotlin
3
star
91

gradle-model-vis

JavaScript
3
star
92

gradle-performance

Gradle performance benchmarks using the Gradle build tool itself
Shell
3
star
93

sbt-build-scan-quickstart

An example project showcasing how to experience the Build Scanยฎ service of Develocity with sbt
Scala
3
star
94

dpeuni-gradle-intro-devs-tasks

Hands-on exercise for DPE University
Java
3
star
95

declarative-samples-android-app

A sample Android application written in the Declarative Gradle DSL, using the prototype Declarative Android `androidApplication` Software Type defined in the `org.gradle.experimental.android-ecosystem` ecosystem plugin.
Kotlin
3
star
96

gradle-groovy-all

Replacement for groovy-all.jar discontinued in Groovy 2.5. This is intended to be used with Gradle only.
Kotlin
3
star
97

declarative-samples-java-app

A sample Java application written in the Declarative Gradle DSL, using the prototype Declarative Java java-application ecosystem plugin.
Java
2
star
98

apachecon2021

Instructions and code repository for the ApacheCon 2021 Gradle Virtual Booth Event
2
star
99

kotlin-relocation-test

Cache relocatability test for Kotlin using Spek
Groovy
2
star
100

github-dependency-submission-demo

Java
2
star