在启用 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/