当前位置: 首页 > 软件库 > 手机/移动开发 > >

android-cache-fix-gradle-plugin

Gradle plugin to fix Android caching problems
授权协议 Apache-2.0 License
开发语言 Java
所属分类 手机/移动开发
软件类型 开源软件
地区 不详
投 递 者 贾实
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

Android cache fix Gradle plugin

CI

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.

  • 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, 7.0.2, 7.1.0-alpha11
  • Supported Kotlin versions: 1.3.70+

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 3.6.2), 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. Typically,this can just be injected from the root project's build.gradle (change '2.4.4' to the latest version of the cache fix pluginhere):

Groovy
plugins {
    id "org.gradle.android.cache-fix" version "2.4.4" apply false
}

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

subprojects {
    plugins.withType<com.android.build.gradle.api.AndroidBasePlugin>() {
        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

The following caching issues are fixed by the cache fix plugin but unresolved in any current or upcoming preview release of the Android Gradle Plugin as of 21.08.2020.

Please star them if you are experiencing them in your project.

Implementation Notes

RoomSchemaLocationWorkaround

Most of the workarounds in this plugin should apply to your project without any changes. However, one workaroundrequires some extra configuration. The Room schema location workaround allows you to specify an output directory forRoom 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/132245929and https://issuetracker.google.com/issues/139438151) which this workaround attempts to mitigate. However, in order todo 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 annotationprocessor argument. If an explicit annotation processor argument is provided, an exception will be thrown, instructingthe user to configure it via the extension:
Groovy
room {
    schemaLocationDir = file("roomSchemas")
}
Kotlin
room {
    schemaLocationDir.set(file("roomSchemas"))
}
  • There can only be a single schema export directory for the project - you cannot configure variant-specific exportdirectories. Schemas exported from different variants will be merged in the directory specified in the "room" extension.

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

It has been observed that caching the MergeNativeLibsTask, StripDebugSymbols, MergeJavaResources, MergeSourceSetFolders, BundleLibraryClassesJar and DataBindingMergeDependencyArtifacts 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 actually disable caching for these tasks.

 相关资料
  • 命令go fix会把指定代码包的所有Go语言源码文件中的旧版本代码修正为新版本的代码。这里所说的版本即Go语言的版本。代码包的所有Go语言源码文件不包括其子代码包(如果有的话)中的文件。修正操作包括把对旧程序调用的代码更换为对新程序调用的代码、把旧的语法更换为新的语法,等等。 这个工具其实非常有用。在编程语言的升级和演进的过程中,难免会对过时的和不够优秀的语法及标准库进行改进。这样的改进对于编程语

  • 修正了 IE 中的水平溢出问题。特别是,IE 会把滚动条放在溢出的元素里面,如果该元素只有一行,滚动条会覆盖这一行。 这个插件会调整填充物来解决这个问题。

  • Universal SafetyNet Fix This is a universal fix for SafetyNet on devices with hardware-backed attestation and unlocked bootloaders (or custom verified boot keys). It defeats both hardware attestation

  • IE6下的PNG图片的透明是个老问题了,不过现在搜到个十分简单的解决方法,只需要一个的JS文件和一个1*1象素的GIF图片即可。 用法 <!--[if lt IE 7]>         <script type="text/javascript" src="unitpngfix.js"></script> <![endif]--> 演示地址:

  • The PNG Fix jQuery plug-in was developed to create a quick-and-easy fix for the PNG transparency issue in Internet Explorer 6. It's partially based on Angus Turnbulls TwinHelix fix, but aims to remove

  • IE PNG Alpha Fix 是一个脚本用来解决IE 5.5 和 6.0 无法使用透明的png图片做背景的问题。 示例代码: <style type="text/css"> img, div { behavior: url(iepngfix.htc) } </style>