flutter permission_handler Build fail

1,098

as said in plugin github repository

These new permissions are supported on Android 12, to resolve this problem make sure to set the compileSdkVersion in your app/build.gradle file to 31.

for more information have a look at here

Share:
1,098
Kevnlan
Author by

Kevnlan

Updated on January 01, 2023

Comments

  • Kevnlan
    Kevnlan over 1 year

    I am trying to add the package permission_handler to my flutter project but I cannot run the app. I get a build error. This is the error I get

    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
    

    I have reverted to an earlier version but I would like to know what is the cause of this error. My compile version is 30

  • Zionnite
    Zionnite over 2 years
    this actually resolved it but i had to add org.gradle.jvmargs=-Xmx4608m to gradle properties and everyting was fixed