【问题标题】:What is the API level of Android R/11 to set in build.gradle in Android Studio?在 Android Studio 的 build.gradle 中设置的 Android R/11 的 API 级别是什么?
【发布时间】:2020-06-08 21:14:08
【问题描述】:

我可以通过 Android Studio Emulator 使用 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"
    }

【问题讨论】:

    标签: android android-11


    【解决方案1】:

    现在Android 11(也称Android R)SDK已经发布,编译SDK版本简单30

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

    不再适用:

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

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

    【讨论】:

    • 是什么原因,'R'变成了30?新的 Android 版本首先使用一个字母,然后使用 API 编号是否很常见?
    猜你喜欢
    • 2016-01-30
    • 1970-01-01
    • 1970-01-01
    • 2011-11-02
    • 1970-01-01
    • 1970-01-01
    • 2013-07-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多