简体   繁体   English

在 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?

I can use API R via Android Studio Emulator.我可以通过 Android Studio Emulator 使用 API R。 I know I can run directly from Android Studio but still I want to set in Gradle level.我知道我可以直接从 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"
    }

Now that the Android 11 (also known as Android R) SDK is released, the compile SDK version is simply 30 :现在 Android 11(也称为 Android R)SDK 发布了,编译 SDK 版本只是30

android {
    compileSdkVersion 30

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

No longer applicable:不再适用:

When Android R was in the preview stage, the compile SDK version was 'android-R' and the target SDK version was 'R' :当 Android R 处于预览阶段时,编译 SDK 版本为'android-R' ,目标 SDK 版本为'R'

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM