[Bug]: LocationRequest.Builder build error on Android using geolocator: ^13.0.1
Please check the following before submitting a new issue.
- [X] I have searched the existing issues.
- [X] I have carefully read the documentation and verified I have added the required platform specific configuration.
Please select affected platform(s)
- [X] Android
- [ ] iOS
- [ ] Linux
- [ ] macOS
- [ ] Web
- [ ] Windows
Steps to reproduce
Create a Flutter project and add geolocator: ^13.0.1 to pubspec.yaml. Configure android/app/build.gradle as shown above. Attempt to build the project for Android (flutter build apk or flutter run on a physical Android device). The build fails with the LocationRequest.Builder error.
This error only happen in android not on ios
Expected results
The app should compile and run successfully on Android devices, allowing geolocation to work as expected without build errors.
Actual results
C:\Users\cacen\AppData\Local\Pub\Cache\hosted\pub.dev\geolocator_android-4.6.1\android\src\main\java\com\baseflow\geolocator\location\FusedLocationClient.java:102: error: cannot find symbol LocationRequest.Builder builder = new LocationRequest.Builder(0); ^ symbol: class Builder location: class LocationRequest C:\Users\cacen\AppData\Local\Pub\Cache\hosted\pub.dev\geolocator_android-4.6.1\android\src\main\java\com\baseflow\geolocator\location\FusedLocationClient.java:102: error: cannot find symbol LocationRequest.Builder builder = new LocationRequest.Builder(0); ^ symbol: class Builder location: class LocationRequest 2 errors
Code sample
This is what i have in the build.gradle
plugins {
id "com.android.application"
id "kotlin-android"
id "dev.flutter.flutter-gradle-plugin"
id "com.google.gms.google-services"
id 'com.google.firebase.crashlytics'
}
android {
compileSdkVersion 34
defaultConfig {
applicationId "com.test.share2"
minSdkVersion 24
targetSdkVersion 34
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}
dependencies {
implementation 'com.google.android.gms:play-services-location:21.3.0'
implementation "androidx.multidex:multidex:2.0.1"
implementation platform('com.google.firebase:firebase-bom:33.4.0')
implementation 'com.google.firebase:firebase-analytics-ktx'
implementation 'com.google.firebase:firebase-auth'
implementation 'com.google.firebase:firebase-firestore'
implementation 'com.google.firebase:firebase-messaging'
implementation 'com.google.firebase:firebase-crashlytics'
}
Screenshots or video
Screenshots or video demonstration
[Upload media here]
Version
geolocator: ^13.0.1
Flutter Doctor output
Doctor output
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.22.2, on Microsoft Windows [Version 10.0.22631.4317], locale en-GB)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[√] Chrome - develop for the web
[X] Visual Studio - develop Windows apps
X Visual Studio not installed; this is necessary to develop Windows apps.
Download at https://visualstudio.microsoft.com/downloads/.
Please install the "Desktop development with C++" workload, including all of its default components
[√] Android Studio (version 2024.1)
[√] VS Code (version 1.94.2)
[√] Connected device (4 available)
[√] Network resources
getting error on play-services-location:21.2.0
Any luck in resolving? I have been fighting the same issue for some time.. Nothing I have tried has worked. Thanks!
Any luck in resolving? I have been fighting the same issue for some time.. Nothing I have tried has worked. Thanks!
No luck brother, I try to lower down the version, clear the cache, clear the project, rebuild everything, and still it didnt work. Good to see I'm not the only one having this problem.
Any luck in resolving? I have been fighting the same issue for some time.. Nothing I have tried has worked. Thanks!
No luck brother, I try to lower down the version, clear the cache, clear the project, rebuild everything, and still it didnt work. Good to see I'm not the only one having this problem.
I sorted it out. Make sure your play-services-location is updated in your grade file.
com.google.android.gms:play-services-location:21.3.0