我正在尝试使用新的通知API setForegroundServiceBehavior。但是,当尝试创建构建时,我得到了一个未解决的引用,我一般相信Android S。(我正在使用Java进行不同的项目,似乎没有问题。)
val builder = Notification.Builder(this, CH_ID)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
builder.setForegroundServiceBehavior(Notification.FOREGROUND_SERVICE_IMMEDIATE);
}
错误:
Unresolved reference: S
Unresolved reference: setForegroundServiceBehavior
Unresolved reference: FOREGROUND_SERVICE_IMMEDIATE
Gradle:
compileSdkVersion 31
buildToolsVersion "30.0.3"
defaultConfig {
...
minSdkVersion 28
targetSdkVersion 31
1条答案
按热度按时间lmvvr0a81#
将您的buildToolsVersion更新为32.0.0,compileSdkVersion和targetSdkVersion更新为32,或更新版本。