Skip to content

Instantly share code, notes, and snippets.

@cdsap
cdsap / Dockerfile
Created May 18, 2023 21:45
Docker file buidling Test Distribution Agent + Android SDK
FROM gradle/gradle-enterprise-test-distribution-agent:2.0.1
USER 0
RUN apt-get update \
&& apt-get install -y wget \
&& apt-get install -y unzip \
&& rm -rf /var/lib/apt/lists/*
USER gradle
RUN mkdir -p /home/gradle/android-sdk
ENV ANDROID_HOME "/home/gradle/android-sdk"
@ghale
ghale / build.gradle
Last active May 20, 2021 00:00
Detecting overlapping outputs
task checkForOverlappingOutputs {
doLast {
def rootNode = new TreeNode()
rootNode.name = ''
// Gather the outputs of all tasks
allprojects {
tasks.all { task ->
try {
task.outputs.files.each { file ->
@ghale
ghale / build.gradle
Last active December 21, 2023 13:41
Build Service for restricting only one test task to execute at a time
import org.gradle.api.services.*
subprojects {
apply plugin: OneTestTaskOnly
}
class OneTestTaskOnly implements Plugin<Project> {
void apply(Project project) {
// Register a service to constrain parallelism of test tasks to 1
Provider<SharedResource> testLimitingService = project.gradle.sharedServices.registerIfAbsent("testLimitingService", SharedResource) { spec ->
@ghale
ghale / captureFingerprints.gradle
Last active July 19, 2023 11:13
Capture task classpath fingerprints
def fingerprinter = services.get(org.gradle.internal.fingerprint.classpath.ClasspathFingerprinter)
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach { task ->
doFirst {
ClassLoader classLoader = task.getClass().classLoader
while (classLoader instanceof URLClassLoader) {
def fingerprints = [] as Set
def allFiles = [] as Set
classLoader.getURLs().each {
fingerprints.add(["${task.path}:${file(it.file).name}", "${fingerprinter.fingerprint(files(it.file)).hash}"])
allFiles.add(file(it.file))
@ghale
ghale / build.gradle
Last active July 11, 2020 12:53
Workaround for MergeResources cache miss
tasks.withType(com.android.build.gradle.tasks.MergeResources) { task ->
Map<String, FileCollection> originalResources = [:]
// Create a synthetic input with the original value and RELATIVE path sensitivity
project.gradle.taskGraph.beforeTask {
if (it == task) {
originalResources.putAll(task.resourcesComputer.resources)
task.resourcesComputer.resources.clear()
task.inputs.files(originalResources.values())
.withPathSensitivity(PathSensitivity.RELATIVE)
.withPropertyName("rawLocalResources.workaround")
/**
* 1) Change agpVersion
* 2) Run './gradlew dumpSources'
* 3) Check changeset into source control
*/
def agpVersion = 'UPDATE_THIS'
repositories {
google()
jcenter()

Build "Sources for Android 29" so you can comfortably browse the Android API source in Android Studio.

  1. Collect source files
mkdir android-sdk-source-build
cd android-sdk-source-build

mkdir -p frameworks/base
@dlew
dlew / script.sh
Created November 9, 2018 16:36
Simple AndroidX Migration Script
#!/usr/bin/env bash
# I've found that the "Migrate to AndroidX" converter in Android Studio doesn't work very
# well, so I wrote my own script to do the simple job of converting package names.
#
# You can download a CSV of package names here: https://developer.android.com/topic/libraries/support-library/downloads/androidx-class-mapping.csv
#
# It'll run faster on a clean build because then there are fewer files to scan over.
#
# Uses `gsed` because I'm on a Mac. Can easily replace with `sed` if you don't have `gsed`.
@jlstrater
jlstrater / bananabread.txt
Last active February 15, 2018 07:29
Banana Bread Recipe
Banana Bread (adapted from the St. Peter's Catholic Church Cookbook from my childhood)
1/2 cup butter (about half a 250g bar) softened
1 1/4 cup sugar (about 250 g)
2 eggs
1 1/2 cup flour (about 180 g)
3/4 tsp baking powder
2 1/2 tsp milk
1/2 tsp vinegar
1 tsp vanilla
@broady
broady / 1MarkerAnimation.java
Last active March 13, 2024 12:44
Animating Markers
/* Copyright 2013 Google Inc.
Licensed under Apache 2.0: http://www.apache.org/licenses/LICENSE-2.0.html */
package com.example.latlnginterpolation;
import android.animation.ObjectAnimator;
import android.animation.TypeEvaluator;
import android.animation.ValueAnimator;
import android.annotation.TargetApi;
import android.os.Build;