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

Nit*_*rma 6 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)
Run Code Online (Sandbox Code Playgroud)

上述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
Run Code Online (Sandbox Code Playgroud)

我应该添加-dontwarn支持后卫的规则和/或添加一些-keep规则吗?

Nil*_*iya 0

这个错误是由缺少类引起的。请在您的应用程序级别 build.gradle中使用以下内容来消除此错误:-

//https://mvnrepository.com/artifact/com.google.errorprone/error_prone_annotations

implementation 'com.google.errorprone:error_prone_annotations:2.23.0'
Run Code Online (Sandbox Code Playgroud)

并与 gradle 同步。感谢您提出这样的问题,并使 SO 社区变得更好。