warnings found and -Werror specified [deprecation] LocationProvider in android.location has been deprecated

I facing the error: warnings found and -Werror specified

/Users/sdaemoninfotech/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/geolocator-6.2.1/android/src/main/java/com/baseflow/geolocator/location/LocationManagerClient.java:10: warning: [deprecation] LocationProvider in android.location has been deprecated
import android.location.LocationProvider;
                       ^
error: warnings found and -Werror specified
/Users/sdaemoninfotech/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/geolocator-6.2.1/android/src/main/java/com/baseflow/geolocator/location/LocationMapper.java:29: warning: [deprecation] isFromMockProvider() in Location has been deprecated
      position.put("is_mocked", location.isFromMockProvider());
                                        ^
1 error
2 warnings
warnings found and -Werror specified

I tried to downgrade flutter too. still facing the error

enter image description here


Solution 1:

I have the following dependencies:

permission_handler: ^8.1.4+2
geolocator: ^7.6.0
geocoding: ^2.0.0

and fix this by updating like this:

permission_handler: ^8.2.5
geolocator: ^7.7.0
geocoding: ^2.0.1

Also have in build.gradle compileSdkVersion 31

and

in gradle.properties

android.useAndroidX=true
android.enableJetifier=true