Fixing `error: cannot find symbol Build.VERSION_CODES.Q`

I am using permissionhandler on a Flutter project, and this just happened.

permission_handler-4.4.0+hotfix.4/android/src/main/java/com/baseflow/permissionhandler/ error: cannot find symbol
                    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
  symbol:   variable Q
  location: class VERSION_CODES
/Users/anhtuan/flutter/.pub-cache/hosted/ error: cannot find symbol
            case Manifest.permission.ACCESS_BACKGROUND_LOCATION:
  location: class permission

According to this post, this is because it's compiling against an old version of Android which doesn't have the variable defined. After changing compileSdkVersion in android/app/build.gradle from 28 to 29, it compiled again.