在我的 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 设备上我的代码运行良好。
我在启用 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)