Baseflow / Baseflow/flutter-geolocator
[Bug]: LocationRequest.Builder build error on Android using geolocator: ^13.0.1
- Dominant language
- Dart
- Stars
- 1.3k
- Forks
- 803
- Avg merge
- 8h 16m
- Merged PRs (30d)
- 1
Description
### Please check the following before submitting a new issue.
- [X] I have searched the [existing issues](https://github.com/baseflow/flutter-geolocator/issues).
- [X] I have carefully [read the documentation](https://github.com/Baseflow/flutter-geolocator/blob/main/geolocator/README.md) 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
```dart
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
```console
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
```
Contributor guide
Research direction
Start with geolocator_android-4.6.1/android/src/main/java/com/baseflow/geolocator/location/FusedLocationClient.java at the reported LocationRequest.Builder line, then review the play-services-location:21.3.0 dependency in android/app/build.gradle. Reproduce with Flutter 3.22.2 using flutter build apk; done means the Android project compiles and runs without the LocationRequest.Builder error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, dart, java
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100