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/PermissionManager.java:315: 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/pub.dartlang.org/permission_handler-4.4.0+hotfix.4/android/src/main/java/com/baseflow/permissionhandler/PermissionUtils.java:34: error: cannot find symbol
case Manifest.permission.ACCESS_BACKGROUND_LOCATION:
^
symbol: variable 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.