Call requires API level 26 (current min is 23): android.content.Context#startForegroundService
指定しているビルド時の最小SDKバージョンが低い場合に出力される。
解決方法
このようなエラーが出た場合は、指定しているビルド時の最小SDKバージョンを変更する。
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 30
buildToolsVersion "30.0.2"
defaultConfig {
applicationId "xxx.xxxxxxxxxxxx"
minSdkVersion 23 // ← ここを26以上に変更
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
変更したら、Sync Nowを押して同期して完了です。
