15

Why I am getting

Cannot resolve symbol 'Q'

when checking if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) with build tools 29.0.0?

From Google: enter image description here So it very much exists already.

Community
  • 1
  • 1
PIXP
  • 2,382
  • 3
  • 19
  • 28

3 Answers3

35

Set your compileSdkVersion to 29 or higher. The buildToolsVersion (if you still have that) does not have an impact on the Android SDK symbols — that is determined by your compileSdkVersion.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Indeed. My mistake. I have two Modules, and I forgot to set the compileSdkVersion in the Library module... – PIXP Jun 10 '19 at 19:56
  • and I don't have buildToolsVersion - I just noticed I only have 29.0.0 installed in the SDK manager – PIXP Jun 10 '19 at 19:57
  • 1
    Using Android Studio 4.1, compileSdkVersion 30, buildTools 30.0.2, same error! Everything's fine in Android Studio 4.0.1. Haven't found a solution yet. – 3c71 Oct 03 '20 at 11:04
  • @3c71 do a global search on `compileSdkVersion` to ensure you don't have an older one somewhere in your project. I found a couple set to `29` in library modules I was using; setting them to 30 solved the problem. – Sterling Nov 01 '20 at 16:15
  • @String, thanks! That's actually the first thing I did, obviously. Everything set to 30 didn't make a difference, only removing an app module without any dependency to the source code involved fixed it! Reported a bug, no answer after more than a month. Funny how people keeps thinking others are stupid. Did you read that it works in 4.0.1 ? It wouldn't if I had an sdkversion lower than 29 involved. – 3c71 Nov 02 '20 at 18:00
5

To fix it, you need to update your compileSdkVersion to 29. While you are at it, might as well update the buildToolsVersion. You can do that by changing these lines in your /android/build.gradle file.

...
buildscript {
    ext {
        ...
        buildToolsVersion = "29.0.3"
        compileSdkVersion = 29
        ...
    }
...
Akshay I
  • 3,675
  • 1
  • 34
  • 57
2

What you can also do is revert your gradle version to 3.5.0, and keep the compileSdkVersion on 28. So, in android/build.gradle:

buildscript {
    ...
    dependencies {
        ...
        classpath 'com.android.tools.build:gradle:3.5.0'
        ...
    }
}

and in your android/app/build.gradle:

...
android {
    compileSdkVersion 28
    ...
}

Versions other than 3.5.0 might work as well, but I haven't tested them.

Aleksandar
  • 3,558
  • 1
  • 39
  • 42