From 3ca564b047db91d707f4d38e19f15e46e5df7dd3 Mon Sep 17 00:00:00 2001 From: Jared Duke Date: Wed, 10 Aug 2022 15:14:06 -0700 Subject: [PATCH] Suppress R8 warnings for support library annotations Most of these annotations are stripped at dex compile-time, and are not necessarily present in the generated dex library's classpath. As the classpath is used to inform R8 about `libraryjars`, this can cause reference failures during R8 execution when warnings are enabled. For now, suppress the reference warnings. Unrecognized runtime-visible annotations will still be kept, and this should unblock efforts to re-enable R8 warnings for many platform targets. A proper solution will be to ensure the appropriate annotation libs are fed as `-libraryjars` to R8. Bug: 242088131 Test: m + `optimize { ignore_warnings: false }` Change-Id: Ie92db2a9725ff520b311c6b66a50feae79463925 --- core/proguard_basic_keeps.flags | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/core/proguard_basic_keeps.flags b/core/proguard_basic_keeps.flags index b5d14fa6b2..38feec37b8 100644 --- a/core/proguard_basic_keeps.flags +++ b/core/proguard_basic_keeps.flags @@ -75,6 +75,19 @@ # has a fallback, but again, don't use Futures.getChecked on Android regardless. -dontwarn java.lang.ClassValue +# Ignore missing annotation references for various support libraries. +# While this is not ideal, it should be relatively safe given that +# 1) runtime-visible annotations will still be kept, and 2) compile-time +# annotations are stripped by R8 anyway. +# Note: The ** prefix is used to accommodate jarjar repackaging. +# TODO(b/242088131): Remove these exemptions after resolving transitive libs +# dependencies that are provided to R8. +-dontwarn **android**.annotation*.** +-dontwarn **com.google.errorprone.annotations.** +-dontwarn javax.annotation.** +-dontwarn org.checkerframework.** +-dontwarn org.jetbrains.annotations.** + # Less spammy. -dontnote