android - 使用 R8 构建发布 apk 时缺少类 com.google.errorprone.annotations.Immutable

标签 android proguard android-r8 tink

在启用 R8 的情况下构建发布 apk 时出现以下错误:

Task :app:minifyReleaseWithR8
AGPBI: {"kind":"warning","text":"Missing classes detected while running R8. Please add the missing classes or apply additional keep rules that are generated in C:\\Users\\y509118\\AndroidStudioProjects\\SafeBox\\app\\build\\outputs\\mapping\\release\\missing_rules.txt.\n","sources":[{}]}
AGPBI: {"kind":"warning","text":"Missing class com.google.errorprone.annotations.Immutable (referenced from: com.google.crypto.tink.KeyTemplate and 4 other contexts)","sources":[{}],"tool":"R8"}
Missing classes detected while running R8. Please add the missing classes or apply additional keep rules that are generated in C:\Users\y509118\AndroidStudioProjects\SafeBox\app\build\outputs\mapping\release\missing_rules.txt.


Missing class com.google.errorprone.annotations.Immutable (referenced from: com.google.crypto.tink.KeyTemplate and 4 other contexts)
上述missing_rules文件的内容:
# Please add these rules to your existing keep rules in order to suppress warnings.
# This is generated automatically by the Android Gradle plugin.-dontwarn com.google.errorprone.annotations.Immutable
我应该添加-dontwarn在 pro-guard 规则中或添加一些 -keep规则?

最佳答案

当涉及到单个文件(而不是整个包)时,您最好保留而不是丢弃任何警告。这对您的 apk 并没有增加太多。

-keep class com.google.errorprone.annotations.Immutable

关于android - 使用 R8 构建发布 apk 时缺少类 com.google.errorprone.annotations.Immutable,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69242193/

相关文章:

android - 如何在导航控件 fragment 中关闭导航 DrawerLayout onBackPressed

android - 资源 NotFoundException

java - 尽管只有一个条目存在,但 Proguard 为重复的 zip 条目抛出 IOException

android - 将带有 proguard 的 Android 项目迁移到 R8,缺少 rt.java 文件,Android Studio 4.2

android - R8 去除反射所需的 Kotlin 伴生对象

android - 获取按钮 ID 而不是整个按钮

android - 将 9patch 和纹理应用到按钮

spring - 与现有的、不兼容的相同名称和类的 bean 定义冲突

Android Gradle Build Plugin 4.0.0 & R8 Desugaring 不适用于 API 19

java - 如何使自定义 ListView 可点击