Build failed error: cannot find symbol if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R)
Solution 1:
Simply upgrade the compileSdkVersion and targetSdkVersion to 31 in your android/app/build.gradle file.
Solution 2:
Build.VERSION_CODES.R
only exists in API 30, but you're compiling with API 29.
The compileSdkVersion should be set to 30 if you want to use Build.VERSION_CODES.R
.
Update for cordova-android@10
As of cordova-android@10, compileSdkVersion
has been removed android-targetSdkVersion
is unified to set both the target & compile SDK versions, so that they always remain consistent.
Solution 3:
Updated-: make sure you set compileSdkVersion
in your android/app/build.gradle file to 31
Old-: I encounter this error while using the Geolocator plugin in the flutter app. to Solve this error you have to open LocationMapper.java (you can find this path in your Debug console). and remove this part
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S)
and also make sure your android compile version is 30 (For GeoLocator Build.gradle)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
position.put("is_mocked", location.isMock());
}