Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot resolve Build.VERSION_CODES.Q with build tools 29 in Android Studio

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.

like image 856
PIXP Avatar asked Jun 10 '19 09:06

PIXP


3 Answers

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.

like image 152
CommonsWare Avatar answered Oct 23 '22 18:10

CommonsWare


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.

like image 37
Aleksandar Avatar answered Oct 23 '22 19:10

Aleksandar


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
        ...
    }
...
like image 43
Akshay I Avatar answered Oct 23 '22 18:10

Akshay I