在 Android Studio 的 build.gradle 中设置 Android R/11 的 API 级别是多少?

What is the API level of Android R/11 to set in build.gradle in Android Studio?

我可以通过 Android Studio 模拟器使用 API R。我知道我可以直接从 Android Studio 运行,但我仍然想设置 Gradle 级别。

android {
    compileSdkVersion 30
    defaultConfig {
        applicationId "com.example.test"
        minSdkVersion 21
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

现在Android11(又名AndroidR)SDK发布了,编译SDK版本就是30:

android {
    compileSdkVersion 30

    defaultConfig {
        targetSdkVersion 30 // Optional: If you want to target R as well
        // ...
    }
    // ... 
}

不再适用:

当AndroidR处于预览阶段时,编译SDK版本为'android-R',目标SDK版本为'R':

android {
    compileSdkVersion 'android-R'

    defaultConfig {
        targetSdkVersion 'R' // Optional: If you want to target R as well
        // ...
    }
    // ... 
}