Skip to content

Instantly share code, notes, and snippets.

View ZacSweers's full-sized avatar

Zac Sweers ZacSweers

View GitHub Profile
@ZacSweers
ZacSweers / Notes.md
Last active January 31, 2023 00:24
MergeFileTask Patch

The Problem

While doing some remote build cache fidelity testing in #66841, I found that our lint analysis tasks were consistently getting cache misses due to an esoteric intermediate proguard file contents change.

After a little digging, I found these files were generated by AGP as a "merged" file of all that project's generated proguard files. This was most notable in projects using Moshi, which generates proguard rules on the fly.

My hunch was that these files were being merged with non-deterministic order, as I couldn't find anything that ensured ordering and this input was purely a file contents check (so the same rules in different order would still constitute a miss).

I was able to verify this was the case via snagging merged proguard.txt files via github actions artifact uploads.

I filed this issue for it here: issuetracker.google.com/issues/266403349 (note it's been made private for some reason).

@ZacSweers
ZacSweers / MoshiBugReport.java
Last active February 15, 2021 06:12
Sample bug report for Moshi
package test;
import static com.google.common.truth.Truth.assertThat;
import com.squareup.moshi.JsonAdapter;
import com.squareup.moshi.Moshi;
import org.junit.Test;
import java.io.IOException;
public class MoshiBugReport {
@ZacSweers
ZacSweers / 1-Before.txt
Last active June 21, 2020 08:02
Dagger new error messages output comparison
/Users/zsweers/dev/android/personal/CatchUp/app/build/generated/source/kapt/debug/io/sweers/catchup/app/CatchUpApplication_HiltComponents.java:188: error: [Dagger/DuplicateBindings] androidx.activity.ComponentActivity is bound multiple times:
public abstract static class ApplicationC implements ApplicationComponent,
^
@org.jetbrains.annotations.NotNull @io.sweers.catchup.injection.scopes.PerActivity @Binds androidx.activity.ComponentActivity io.sweers.catchup.injection.ActivityModule.provideComponentActivity(T)
@org.jetbrains.annotations.NotNull @io.sweers.catchup.injection.scopes.PerActivity @Binds androidx.activity.ComponentActivity io.sweers.catchup.ui.about.AboutActivity.Module.provideComponentActivity(io.sweers.catchup.ui.about.AboutActivity)
@org.jetbrains.annotations.NotNull @io.sweers.catchup.injection.scopes.PerActivity @Binds androidx.activity.ComponentActivity io.sweers.catchup.ui.activity.MainActivity.ServiceIntegrationModule.provideComponentActivity(io
@ZacSweers
ZacSweers / WeakMutableSet.kt
Created October 25, 2019 23:55
A weak Set & MutableSet implementation in Kotlin.
/*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* glassfish/bootstrap/legal/CDDLv1.0.txt or
* https://glassfish.dev.java.net/public/CDDLv1.0.html.
* See the License for the specific language governing
@ZacSweers
ZacSweers / InlineMask.kt
Created September 11, 2019 07:50
Inline mask
// Code generated by moshi-kotlin-codegen. Do not edit.
package com.squareup.moshi.kotlin.codgen
import com.squareup.moshi.JsonAdapter
import com.squareup.moshi.JsonReader
import com.squareup.moshi.JsonWriter
import com.squareup.moshi.Moshi
import com.squareup.moshi.Types
import com.squareup.moshi.internal.Util
import java.lang.NullPointerException
@ZacSweers
ZacSweers / After.kt
Created September 8, 2019 03:43
Missing/null property before/after
// Code generated by moshi-kotlin-codegen. Do not edit.
package com.squareup.moshi.kotlin.codgen
import com.squareup.moshi.JsonAdapter
import com.squareup.moshi.JsonReader
import com.squareup.moshi.JsonWriter
import com.squareup.moshi.Moshi
import com.squareup.moshi.Types
import com.squareup.moshi.internal.Util
import java.lang.NullPointerException
@ZacSweers
ZacSweers / SmokeTestTypeJsonAdapter.kt
Last active September 8, 2019 03:38
Dynamic invocation
// Code generated by moshi-kotlin-codegen. Do not edit.
package com.squareup.moshi.kotlin.codgen
import com.squareup.moshi.JsonAdapter
import com.squareup.moshi.JsonDataException
import com.squareup.moshi.JsonReader
import com.squareup.moshi.JsonWriter
import com.squareup.moshi.Moshi
import com.squareup.moshi.Types
import com.squareup.moshi.internal.Util
We couldn’t find that file to show.
fun String.extension(): String = removePrefix("hello")
val lambda: (String) -> String = { it.removePrefix("hello") }
val lambdaWithReceiver: String.() -> String = { removePrefix("hello") }
fun function(arg: (String) -> String) {
}
fun function2(arg: String.() -> String) {
}
@ZacSweers
ZacSweers / BlurrinessDetection.kt
Last active August 5, 2022 03:18
Demo implementation of client-side image blurriness detection on Android using renderscript.
/*
* Copyright (c) 2018. Uber Technologies
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software