flutterpermission_handler构建失败

Kev*_*lan 2 permissions flutter flutter-packages

我正在尝试将包permission_handler添加到我的flutter项目中,但我无法运行该应用程序。我收到构建错误。这是我得到的错误

C:\Users\Hp\dev\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:\Users\Hp\dev\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:\Users\Hp\dev\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:\Users\Hp\dev\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:\Users\Hp\dev\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:\Users\Hp\dev\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:\Users\Hp\dev\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:\Users\Hp\dev\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
8 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 2m 48s
Run Code Online (Sandbox Code Playgroud)

我已恢复到早期版本,但我想知道此错误的原因是什么。我的编译版本是30

小智 7

正如插件 github 存储库中所述

Android 12 支持这些新权限,要解决此问题,请确保将 app/build.gradle 文件中的compileSdkVersion 设置为31。

欲了解更多信息,请查看此处