In trying to emulate the application now, the terminal throws an exception and the application won't start:
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:processDebugResources'.
> Could not resolve all task dependencies for configuration ':app:debugRuntimeClasspath'.
> Could not resolve com.google.android.gms:play-services-location:16.+.
Required by:
project :app > project :location
> Failed to list versions for com.google.android.gms:play-services-location.
> Unable to load Maven meta-data from https://google.bintray.com/exoplayer/com/google/android/gms/play-services-location/maven-metadata.xml.
> Could not get resource 'https://google.bintray.com/exoplayer/com/google/android/gms/play-services-location/maven-metadata.xml'.
> Could not GET 'https://google.bintray.com/exoplayer/com/google/android/gms/play-services-location/maven-metadata.xml'. Received status code 502 from server: Bad Gateway
* 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 37s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)
Flutter doctor result:
[√] Flutter (Channel stable, 1.22.5, on Microsoft Windows [versão 10.0.19041.1348], locale pt-BR)
[√] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
[√] Android Studio (version 3.6)
[√] Connected device (1 available)
I've already tried replacing "jcenter" in * project / android / build.gradle * passing * mavenCentral * in place as follows, as reported here and here, but that didn't fix the problem
repositories {
google()
mavenCentral()
maven {
url "https://maven.google.com"
}
}
The project was working normally and this occurred at this time.
In an attempt to emulate the application one more time, before displaying the error on the terminal it showed me the following message: "Plugin project :location_web not found. Please update settings.gradle." and I found that in my project the error was caused by the location package, which has a dependency on location_web
Solution That said, until they fix the problem, the solution is not to use the "location" package and replace it with one that doesn't have this location_web dependency. I did it using the "geolocator" package and in my case I needed it to get the geographic coordinates and call another function that returned the address data, looking like this:
On pubspec.yaml:
# location: ^3.0.0
geolocator: '6.2.1'
And I executed command:
flutter pub get
In AndroidManifest files, I added:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION"/>
For what I needed, which was to get the geographic coordinates, I did it as follows using "geolocator", replacing the previous code that used the "location" package:
import 'package:geolocator/geolocator.dart';
Future _obtemCoordenadas() async {
LocationPermission permissao;
Position _dadosLocalizacao;
await Geolocator.requestPermission();
permissao = await Geolocator.checkPermission();
if (permissao == LocationPermission.denied) {
permissao = await Geolocator.requestPermission();
if (permissao == LocationPermission.denied) {
return;
}
}
if (permissao == LocationPermission.deniedForever) {
return;
}
if (permissao == LocationPermission.always) {
_dadosLocalizacao = await Geolocator.getCurrentPosition();
var latitude = _dadosLocalizacao.latitude;
var longitude = _dadosLocalizacao.longitude;
localizacao.latitude = latitude.toString();
localizacao.longitude = longitude.toString();
}
}