flutterdartflutter-dependenciesandroid-permissionsandroid-handler

How to solve permission handler error in flutter?


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.

Compilation failed; see the compiler error output for details.

BUILD FAILED in 1m 10s Exception: Gradle task assembleDebug failed with exit code 1 ``` Below I attached necessary screenshots flutter doctor -v 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.


Solution

  • Try flutter clean, delete the pubspec.lock file. Then run flutter pub get and then flutter run. It should resolve the issue.