How to solve permission handler error in flutter?
Solution 1
Try flutter clean, delete the pubspec.lock file. Then run flutter pub get and then flutter run. It should resolve the issue.
Solution 2
Changing the compileSdkVersion to 30 or 31 in android\app\build.gradle can fix this issue
shanmkha
Updated on January 02, 2023Comments
-
shanmkha over 1 year
Not sure where I made mistake but I got error while implementing permission_handler: ^7.1.0 ,the error message is ``` C:\src\flutter.pub-cache\hosted\http://pub.dartlang.org\permission_handler-7.2.0\android\src\main\java\com\baseflow\permissionhandler\ServiceManager.java:152: warning: [deprecation] getDefaultAdapter() in BluetoothAdapter has been deprecated final BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); ^ error: warnings found and -Werror specified 1 error 1 warning
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 1m 10s Exception: Gradle task assembleDebug failed with exit code 1 ``` Below I attached necessary screenshots And I also given permission in Androidmanifest
<uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
And compileSdkVersion 31, minSdkVersion 21, targetSdkVersion 30. Hope I have given all necessary details. If anything need please comment and please help to solve this issue and I don’t want to change my sdk version. Thank you in Advance.
-
shanmkha over 2 yearsNo @kaushik still getting same error
-
Kaushik Chandru over 2 yearsIn pubspec.yaml file give
permission_handler:any
and try once please -
shanmkha over 2 yearsIam getting same error dude @kaushik
-
Kaushik Chandru over 2 yearsPaste the full error here.
-
shanmkha over 2 yearsAfter permission_handler: any and doing flutter clean , delete the pubspec.lock file. Then run flutter pub get and then flutter run , it working fine without any error.but how can I know which version it is using because we gave it as “any”?
-
Kaushik Chandru over 2 yearsRun flutter pub outdated. It will list all packages and it's versions too
-
shanmkha over 2 yearsHey @Kaushik I posed another question can you please go through this link. Thank You.