7

I can use API R via Android Studio Emulator. I know I can run directly from Android Studio but still I want to set in Gradle level.

android {
    compileSdkVersion 30
    defaultConfig {
        applicationId "com.example.test"
        minSdkVersion 21
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
Ryan M
  • 18,333
  • 31
  • 67
  • 74
Pooja Singh
  • 149
  • 2
  • 10

1 Answers1

14

Now that the Android 11 (also known as Android R) SDK is released, the compile SDK version is simply 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 {
    compileSdkVersion 'android-R'

    defaultConfig {
        targetSdkVersion 'R' // Optional: If you want to target R as well
        // ...
    }
    // ... 
}
Ryan M
  • 18,333
  • 31
  • 67
  • 74
  • 1
    What is the reason, the 'R' have been changed to 30? Is it common for new Android releases first use a letter and next the API number? – Knight of Ni Jul 13 '20 at 17:46