Flutter Version: 2.6.0-12.0.pre.381
Dart Version: 2.15.0
Gradle version : distributionUrl=https://services.gradle.org/distributions/gradle-6.7-all.zip
In pubspec.yaml, I have these packages:
environment:
sdk: ">=2.12.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
splashscreen: ^1.2.0
bottom_navy_bar:
cupertino_icons: ^1.0.2
image_picker: ^0.8.0+4
fluttertoast: ^8.0.7
shared_preferences: ^2.0.6
share: ^2.0.4
flutter_barcode_scanner: ^2.0.0-nullsafety.0
dropdown_search: ^1.0.0
syncfusion_flutter_pdfviewer:
ndialog: ^4.1.0
flutter_pdfview: ^1.0.4
http: ^0.13.3
dio: ^4.0.0
path_provider: ^2.0.3
downloads_path_provider_28: ^0.1.2
permission_handler: ^8.1.4+2
open_file: ^3.2.1
flutter_local_notifications: ^9.0.0
Same packages are working in another project.
Any suggestions on how to fix the problem. I think it is due to some error in build.graddle.
I have changed minSdkVersion and targetSdkVersion in build.gradle as follows:
minSdkVersion 23
targetSdkVersion 29
multiDexEnabled true
It is showing error while running the project:
Launching libmain.dart on SM M205F in debug mode...
Running Gradle task 'assembleDebug'...
Note: C:flutter.pub-cachehostedpub.dartlang.orgdownloads_path_provider_28-0.1.2androidsrcmainjavaitnplacedownloadspathproviderDownloadsPathProviderPlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: C:flutter.pub-cachehostedpub.dartlang.orgimage_picker-0.8.4+2androidsrcmainjavaioflutterpluginsimagepickerImagePickerDelegate.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
C:flutter.pub-cachehostedpub.dartlang.orgpermission_handler-8.2.5androidsrcmainjavacombaseflowpermissionhandlerPermissionManager.java:58: error: cannot find symbol
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
^
symbol: variable R
location: class VERSION_CODES
C:flutter.pub-cachehostedpub.dartlang.orgpermission_handler-8.2.5androidsrcmainjavacombaseflowpermissionhandlerPermissionManager.java:59: error: cannot find symbol
status = Environment.isExternalStorageManager()
^
symbol: method isExternalStorageManager()
location: class Environment
C:flutter.pub-cachehostedpub.dartlang.orgpermission_handler-8.2.5androidsrcmainjavacombaseflowpermissionhandlerPermissionManager.java:254: error: cannot find symbol
if (permission == PermissionConstants.PERMISSION_GROUP_MANAGE_EXTERNAL_STORAGE && Build.VERSION.SDK_INT < Build.VERSION_CODES.R) {
^
symbol: variable R
location: class VERSION_CODES
C:flutter.pub-cachehostedpub.dartlang.orgpermission_handler-8.2.5androidsrcmainjavacombaseflowpermissionhandlerPermissionManager.java:268: error: cannot find symbol
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && permission == PermissionConstants.PERMISSION_GROUP_MANAGE_EXTERNAL_STORAGE) {
^
symbol: variable R
location: class VERSION_CODES
C:flutter.pub-cachehostedpub.dartlang.orgpermission_handler-8.2.5androidsrcmainjavacombaseflowpermissionhandlerPermissionManager.java:270: error: cannot find symbol
Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION,
^
symbol: variable ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION
location: class Settings
C:flutter.pub-cachehostedpub.dartlang.orgpermission_handler-8.2.5androidsrcmainjavacombaseflowpermissionhandlerPermissionManager.java:321: error: cannot find symbol
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S) {
^
symbol: variable S
location: class VERSION_CODES
C:flutter.pub-cachehostedpub.dartlang.orgpermission_handler-8.2.5androidsrcmainjavacombaseflowpermissionhandlerPermissionManager.java:349: error: cannot find symbol
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) {
^
symbol: variable R
location: class VERSION_CODES
C:flutter.pub-cachehostedpub.dartlang.orgpermission_handler-8.2.5androidsrcmainjavacombaseflowpermissionhandlerPermissionManager.java:380: error: cannot find symbol
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) {
^
symbol: variable R
location: class VERSION_CODES
C:flutter.pub-cachehostedpub.dartlang.orgpermission_handler-8.2.5androidsrcmainjavacombaseflowpermissionhandlerPermissionManager.java:384: error: cannot find symbol
return Environment.isExternalStorageManager()
^
symbol: method isExternalStorageManager()
location: class Environment
C:flutter.pub-cachehostedpub.dartlang.orgpermission_handler-8.2.5androidsrcmainjavacombaseflowpermissionhandlerPermissionUtils.java:64: error: cannot find symbol
case Manifest.permission.MANAGE_EXTERNAL_STORAGE:
^
symbol: variable MANAGE_EXTERNAL_STORAGE
location: class permission
C:flutter.pub-cachehostedpub.dartlang.orgpermission_handler-8.2.5androidsrcmainjavacombaseflowpermissionhandlerPermissionUtils.java:72: error: cannot find symbol
case Manifest.permission.BLUETOOTH_SCAN:
^
symbol: variable BLUETOOTH_SCAN
location: class permission
C:flutter.pub-cachehostedpub.dartlang.orgpermission_handler-8.2.5androidsrcmainjavacombaseflowpermissionhandlerPermissionUtils.java:74: error: cannot find symbol
case Manifest.permission.BLUETOOTH_ADVERTISE:
^
symbol: variable BLUETOOTH_ADVERTISE
location: class permission
C:flutter.pub-cachehostedpub.dartlang.orgpermission_handler-8.2.5androidsrcmainjavacombaseflowpermissionhandlerPermissionUtils.java:76: error: cannot find symbol
case Manifest.permission.BLUETOOTH_CONNECT:
^
symbol: variable BLUETOOTH_CONNECT
location: class permission
C:flutter.pub-cachehostedpub.dartlang.orgpermission_handler-8.2.5androidsrcmainjavacombaseflowpermissionhandlerPermissionUtils.java:235: error: cannot find symbol
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && hasPermissionInManifest(context, permissionNames, Manifest.permission.MANAGE_EXTERNAL_STORAGE ))
^
symbol: variable R
location: class VERSION_CODES
C:flutter.pub-cachehostedpub.dartlang.orgpermission_handler-8.2.5androidsrcmainjavacombaseflowpermissionhandlerPermissionUtils.java:235: error: cannot find symbol
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && hasPermissionInManifest(context, permissionNames, Manifest.permission.MANAGE_EXTERNAL_STORAGE ))
^
symbol: variable MANAGE_EXTERNAL_STORAGE
location: class permission
C:flutter.pub-cachehostedpub.dartlang.orgpermission_handler-8.2.5androidsrcmainjavacombaseflowpermissionhandlerPermissionUtils.java:236: error: cannot find symbol
permissionNames.add(Manifest.permission.MANAGE_EXTERNAL_STORAGE);
^
symbol: variable MANAGE_EXTERNAL_STORAGE
location: class permission
C:flutter.pub-cachehostedpub.dartlang.orgpermission_handler-8.2.5androidsrcmainjavacombaseflowpermissionhandlerPermissionUtils.java:259: error: cannot find symbol
String result = determineBluetoothPermission(context, Manifest.permission.BLUETOOTH_SCAN);
^
symbol: variable BLUETOOTH_SCAN
location: class permission
C:flutter.pub-cachehostedpub.dartlang.orgpermission_handler-8.2.5androidsrcmainjavacombaseflowpermissionhandlerPermissionUtils.java:270: error: cannot find symbol
String result = determineBluetoothPermission(context, Manifest.permission.BLUETOOTH_ADVERTISE);
^
symbol: variable BLUETOOTH_ADVERTISE
location: class permission
C:flutter.pub-cachehostedpub.dartlang.orgpermission_handler-8.2.5androidsrcmainjavacombaseflowpermissionhandlerPermissionUtils.java:281: error: cannot find symbol
String result = determineBluetoothPermission(context, Manifest.permission.BLUETOOTH_CONNECT);
^
symbol: variable BLUETOOTH_CONNECT
location: class permission
C:flutter.pub-cachehostedpub.dartlang.orgpermission_handler-8.2.5androidsrcmainjavacombaseflowpermissionhandlerPermissionUtils.java:370: error: cannot find symbol
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S && hasPermissionInManifest(context, null, permission )) {
^
symbol: variable S
location: class VERSION_CODES
20 errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':permission_handler:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 44s
Exception: Gradle task assembleDebug failed with exit code 1
4
Answers
I changed permission_handler: ^8.1.4+2 with permission_handler: 6.0.0 in pubspec.yaml .Now project is working fine. Thanks for your assistance.
I think that
Build.VERSION_CODES.R
is API Level 30 , so setting compileSdkVersion to 30 should fix the issue .This is happing due to
compileSdkVersion
. Head over toandroid/app/build.gradle
and changecomplieSdkVersion
to 31.In
pubspec.yaml
file :-The error must be happening in versions 8.2.0 and onwards. If you still encounter some error then install a version less 8.2.0.
Faced the same issue and this is how i solved it:
First i removed permission_handler from my yaml file.
Then did a flutter clean.
In pubspec.yaml : I changed the version of the permission_handler plugin from 8.2.6 to:
Then In android/app/build.grale file:changed compile sdk version to 31.