9

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 lib\main.dart on SM M205F in debug mode... Running Gradle task 'assembleDebug'... Note: C:\flutter\.pub-cache\hosted\pub.dartlang.org\downloads_path_provider_28-0.1.2\android\src\main\java\it\nplace\downloadspathprovider\DownloadsPathProviderPlugin.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-cache\hosted\pub.dartlang.org\image_picker-0.8.4+2\android\src\main\java\io\flutter\plugins\imagepicker\ImagePickerDelegate.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. C:\flutter\.pub-cache\hosted\pub.dartlang.org\permission_handler-8.2.5\android\src\main\java\com\baseflow\permissionhandler\PermissionManager.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-cache\hosted\pub.dartlang.org\permission_handler-8.2.5\android\src\main\java\com\baseflow\permissionhandler\PermissionManager.java:59: error: cannot find symbol status = Environment.isExternalStorageManager() ^ symbol: method isExternalStorageManager() location: class Environment C:\flutter\.pub-cache\hosted\pub.dartlang.org\permission_handler-8.2.5\android\src\main\java\com\baseflow\permissionhandler\PermissionManager.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-cache\hosted\pub.dartlang.org\permission_handler-8.2.5\android\src\main\java\com\baseflow\permissionhandler\PermissionManager.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-cache\hosted\pub.dartlang.org\permission_handler-8.2.5\android\src\main\java\com\baseflow\permissionhandler\PermissionManager.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-cache\hosted\pub.dartlang.org\permission_handler-8.2.5\android\src\main\java\com\baseflow\permissionhandler\PermissionManager.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-cache\hosted\pub.dartlang.org\permission_handler-8.2.5\android\src\main\java\com\baseflow\permissionhandler\PermissionManager.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-cache\hosted\pub.dartlang.org\permission_handler-8.2.5\android\src\main\java\com\baseflow\permissionhandler\PermissionManager.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-cache\hosted\pub.dartlang.org\permission_handler-8.2.5\android\src\main\java\com\baseflow\permissionhandler\PermissionManager.java:384: error: cannot find symbol return Environment.isExternalStorageManager() ^ symbol: method isExternalStorageManager() location: class Environment C:\flutter\.pub-cache\hosted\pub.dartlang.org\permission_handler-8.2.5\android\src\main\java\com\baseflow\permissionhandler\PermissionUtils.java:64: error: cannot find symbol case Manifest.permission.MANAGE_EXTERNAL_STORAGE: ^ symbol: variable MANAGE_EXTERNAL_STORAGE location: class permission C:\flutter\.pub-cache\hosted\pub.dartlang.org\permission_handler-8.2.5\android\src\main\java\com\baseflow\permissionhandler\PermissionUtils.java:72: error: cannot find symbol case Manifest.permission.BLUETOOTH_SCAN: ^ symbol: variable BLUETOOTH_SCAN location: class permission C:\flutter\.pub-cache\hosted\pub.dartlang.org\permission_handler-8.2.5\android\src\main\java\com\baseflow\permissionhandler\PermissionUtils.java:74: error: cannot find symbol case Manifest.permission.BLUETOOTH_ADVERTISE: ^ symbol: variable BLUETOOTH_ADVERTISE location: class permission C:\flutter\.pub-cache\hosted\pub.dartlang.org\permission_handler-8.2.5\android\src\main\java\com\baseflow\permissionhandler\PermissionUtils.java:76: error: cannot find symbol case Manifest.permission.BLUETOOTH_CONNECT: ^ symbol: variable BLUETOOTH_CONNECT location: class permission C:\flutter\.pub-cache\hosted\pub.dartlang.org\permission_handler-8.2.5\android\src\main\java\com\baseflow\permissionhandler\PermissionUtils.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-cache\hosted\pub.dartlang.org\permission_handler-8.2.5\android\src\main\java\com\baseflow\permissionhandler\PermissionUtils.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-cache\hosted\pub.dartlang.org\permission_handler-8.2.5\android\src\main\java\com\baseflow\permissionhandler\PermissionUtils.java:236: error: cannot find symbol permissionNames.add(Manifest.permission.MANAGE_EXTERNAL_STORAGE); ^ symbol: variable MANAGE_EXTERNAL_STORAGE location: class permission C:\flutter\.pub-cache\hosted\pub.dartlang.org\permission_handler-8.2.5\android\src\main\java\com\baseflow\permissionhandler\PermissionUtils.java:259: error: cannot find symbol String result = determineBluetoothPermission(context, Manifest.permission.BLUETOOTH_SCAN); ^ symbol: variable BLUETOOTH_SCAN location: class permission C:\flutter\.pub-cache\hosted\pub.dartlang.org\permission_handler-8.2.5\android\src\main\java\com\baseflow\permissionhandler\PermissionUtils.java:270: error: cannot find symbol String result = determineBluetoothPermission(context, Manifest.permission.BLUETOOTH_ADVERTISE); ^ symbol: variable BLUETOOTH_ADVERTISE location: class permission C:\flutter\.pub-cache\hosted\pub.dartlang.org\permission_handler-8.2.5\android\src\main\java\com\baseflow\permissionhandler\PermissionUtils.java:281: error: cannot find symbol String result = determineBluetoothPermission(context, Manifest.permission.BLUETOOTH_CONNECT); ^ symbol: variable BLUETOOTH_CONNECT location: class permission C:\flutter\.pub-cache\hosted\pub.dartlang.org\permission_handler-8.2.5\android\src\main\java\com\baseflow\permissionhandler\PermissionUtils.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 4

10

This is happing due to compileSdkVersion. Head over to android/app/build.gradle and change complieSdkVersion to 31.

android { compileSdkVersion 31 ... } 

In pubspec.yaml file :-

dependencies: permission_handler: ^8.2.5 

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.

Sign up to request clarification or add additional context in comments.

1 Comment

In my case I didn't install permission handler, but it was a dependency of one of the packages I installed (form_builder_file_picker)
2

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. Clean Cache

In pubspec.yaml : I changed the version of the permission_handler plugin from 8.2.6 to:

permission_handler: ^8.2.0 

permission_handler

Then In android/app/build.grale file:changed compile sdk version to 31.

2 Comments

Changing compile SDK to version 31 is enough. The alternative solution is reverting permission_handler to 8.2.0, not both.
The error continued to persist on my end even after changing to 31
1

I think that Build.VERSION_CODES.R is API Level 30 , so setting compileSdkVersion to 30 should fix the issue .

2 Comments

It didn't work. It is showing same error again.
The problem was happening because of permission_handler: ^8.1.4+2 package. I removed the package and ran the project it is working now. Only I have to add another package please suggest alternate package.
1

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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.