小编Nit*_*rma的帖子

如果我在 android 代码中使用 java.lang.Iterable#forEach,Lint 会给出错误

在我的 android 代码(Kotlin)中,我使用 java iterable 的 forEach 方法。

mandatoryViews.forEach { view ->
   // my code here
}
Run Code Online (Sandbox Code Playgroud)

下面是我在 build.gradle (app) 中的 sdk 配置:

minSdkVersion 23
targetSdkVersion 30
Run Code Online (Sandbox Code Playgroud)

现在我的代码构建得很好。我还尝试在 API 23 像素设备上运行它,一切正常。

但在我运行gradlew lint查看 lint 错误后,它失败并报告给我以下错误: Call requires API level 24 (current min is 23): java.lang.Iterable#forEach

棉绒错误

无法弄清楚为什么 lint 认为它在 API 23 上不起作用,而在 API 23 设备上我的代码运行良好。

java android lint kotlin android-lint

11
推荐指数
1
解决办法
4907
查看次数

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

我在启用 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 …
Run Code Online (Sandbox Code Playgroud)

android proguard android-r8 tink

6
推荐指数
1
解决办法
4320
查看次数

标签 统计

android ×2

android-lint ×1

android-r8 ×1

java ×1

kotlin ×1

lint ×1

proguard ×1

tink ×1