Hello everyone i am a beginner in Flutter Development, i want to use the Geolocator library to get the current location of the user, but when i tried to running the app, the build application process is failed
I have tried to set the configuration of my AndroidManifest dan the build.gradle file and i have tried to downgrade the version of the geolocator library in pubspec.yaml too, but error is still occured
here are the details of the error that I am facing :
1: Task failed with an exception.
-----------
* Where:
Build file 'C:AppData\Local\Pub\Cache\hosted\pub.dev\geolocator_android-4.6.2\android\build.gradle' line: 29
* What went wrong:
A problem occurred evaluating project ':geolocator_android'.
> Could not get unknown property 'flutter' for extension 'android' of type com.android.build.gradle.LibraryExtension.
2: Task failed with an exception.
-----------
* What went wrong:
A problem occurred configuring project ':geolocator_android'.
> Failed to notify project evaluation listener.
> Cannot invoke method substring() on null object
> compileSdkVersion is not specified. Please add it to build.gradle
3: Task failed with an exception.
-----------
* What went wrong:
Failed to query the value of property 'buildFlowServiceProperty'.
> Could not isolate value .jetbrains.kotlin.gradle.plugin.statistics.BuildFlowService$Parameters_Decorated@24dd914a of type BuildFlowService.Parameters
> A problem occurred configuring project ':geolocator_android'.
> Failed to notify project evaluation listener.
> Cannot invoke method substring() on null object
> compileSdkVersion is not specified. Please add it to build.gradle
here is the configuration of my app : AndroidManifest.xml
<manifest xmlns:android=";>
<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" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_LOCATION" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<application
android:label="story_app"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:exported="true"
android:launchMode="singleTop"
android:taskAffinity=""
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
<meta-data android:name="com.google.android.geo.API_KEY"
android:value=""/>
</application>
<!-- Required to query activities that can process text, see:
and
.
In particular, this is used by the Flutter engine in io.flutter.plugin.text.ProcessTextPlugin. -->
<queries>
<intent>
<action android:name="android.intent.action.PROCESS_TEXT"/>
<data android:mimeType="text/plain"/>
</intent>
</queries>
</manifest>
build.gradle :
plugins {
id "com.android.application"
id "kotlin-android"
// The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
id "dev.flutter.flutter-gradle-plugin"
}
android {
namespace = "com.example.story_app"
compileSdk = 35
ndkVersion = flutter.ndkVersion
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8
}
defaultConfig {
// TODO: Specify your own unique Application ID (.html).
applicationId = "com.example.story_app"
// You can update the following values to match your application needs.
// For more information, see: /to/review-gradle-config.
minSdk = 21
targetSdk = flutter.targetSdkVersion
versionCode = flutter.versionCode
versionName = flutter.versionName
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig = signingConfigs.debug
}
}
}
flutter {
source = "../.."
}
settings.gradle :
pluginManagement {
def flutterSdkPath = {
def properties = new Properties()
file("local.properties").withInputStream { properties.load(it) }
def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
return flutterSdkPath
}()
includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}
plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "8.3.0" apply false
id ".jetbrains.kotlin.android" version "1.9.0" apply false
}
include ":app"
pubspec.yaml :
version: 1.0.0+1
environment:
sdk: ^3.5.4
# Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions
# consider running `flutter pub upgrade --major-versions`. Alternatively,
# dependencies can be manually updated by changing the version numbers below to
# the latest version available on pub.dev. To see which dependencies have newer
# versions available, run `flutter pub outdated`.
dependencies:
flutter:
sdk: flutter
http: ^0.13.3
fluttertoast: ^8.2.0
shared_preferences: ^2.2.3
image_picker: ^1.1.2
image: ^4.0.15
go_router: ^14.2.6
google_maps_flutter: ^2.10.0
geolocator: ^13.0.3
permission_handler: ^11.4.0
Hello everyone i am a beginner in Flutter Development, i want to use the Geolocator library to get the current location of the user, but when i tried to running the app, the build application process is failed
I have tried to set the configuration of my AndroidManifest dan the build.gradle file and i have tried to downgrade the version of the geolocator library in pubspec.yaml too, but error is still occured
here are the details of the error that I am facing :
1: Task failed with an exception.
-----------
* Where:
Build file 'C:AppData\Local\Pub\Cache\hosted\pub.dev\geolocator_android-4.6.2\android\build.gradle' line: 29
* What went wrong:
A problem occurred evaluating project ':geolocator_android'.
> Could not get unknown property 'flutter' for extension 'android' of type com.android.build.gradle.LibraryExtension.
2: Task failed with an exception.
-----------
* What went wrong:
A problem occurred configuring project ':geolocator_android'.
> Failed to notify project evaluation listener.
> Cannot invoke method substring() on null object
> compileSdkVersion is not specified. Please add it to build.gradle
3: Task failed with an exception.
-----------
* What went wrong:
Failed to query the value of property 'buildFlowServiceProperty'.
> Could not isolate value .jetbrains.kotlin.gradle.plugin.statistics.BuildFlowService$Parameters_Decorated@24dd914a of type BuildFlowService.Parameters
> A problem occurred configuring project ':geolocator_android'.
> Failed to notify project evaluation listener.
> Cannot invoke method substring() on null object
> compileSdkVersion is not specified. Please add it to build.gradle
here is the configuration of my app : AndroidManifest.xml
<manifest xmlns:android="http://schemas.android/apk/res/android">
<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" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_LOCATION" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<application
android:label="story_app"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:exported="true"
android:launchMode="singleTop"
android:taskAffinity=""
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
<meta-data android:name="com.google.android.geo.API_KEY"
android:value=""/>
</application>
<!-- Required to query activities that can process text, see:
https://developer.android/training/package-visibility and
https://developer.android/reference/android/content/Intent#ACTION_PROCESS_TEXT.
In particular, this is used by the Flutter engine in io.flutter.plugin.text.ProcessTextPlugin. -->
<queries>
<intent>
<action android:name="android.intent.action.PROCESS_TEXT"/>
<data android:mimeType="text/plain"/>
</intent>
</queries>
</manifest>
build.gradle :
plugins {
id "com.android.application"
id "kotlin-android"
// The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
id "dev.flutter.flutter-gradle-plugin"
}
android {
namespace = "com.example.story_app"
compileSdk = 35
ndkVersion = flutter.ndkVersion
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android/studio/build/application-id.html).
applicationId = "com.example.story_app"
// You can update the following values to match your application needs.
// For more information, see: https://flutter.dev/to/review-gradle-config.
minSdk = 21
targetSdk = flutter.targetSdkVersion
versionCode = flutter.versionCode
versionName = flutter.versionName
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig = signingConfigs.debug
}
}
}
flutter {
source = "../.."
}
settings.gradle :
pluginManagement {
def flutterSdkPath = {
def properties = new Properties()
file("local.properties").withInputStream { properties.load(it) }
def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
return flutterSdkPath
}()
includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}
plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "8.3.0" apply false
id ".jetbrains.kotlin.android" version "1.9.0" apply false
}
include ":app"
pubspec.yaml :
version: 1.0.0+1
environment:
sdk: ^3.5.4
# Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions
# consider running `flutter pub upgrade --major-versions`. Alternatively,
# dependencies can be manually updated by changing the version numbers below to
# the latest version available on pub.dev. To see which dependencies have newer
# versions available, run `flutter pub outdated`.
dependencies:
flutter:
sdk: flutter
http: ^0.13.3
fluttertoast: ^8.2.0
shared_preferences: ^2.2.3
image_picker: ^1.1.2
image: ^4.0.15
go_router: ^14.2.6
google_maps_flutter: ^2.10.0
geolocator: ^13.0.3
permission_handler: ^11.4.0
Share
Improve this question
asked Mar 21 at 3:57
DzyDzy
3391 gold badge3 silver badges13 bronze badges
2
- What is the output of running flutter doctor in the terminal? – tomerpacific Commented Mar 21 at 5:39
- heloo, i have found the error, it seems that my flutter version is the issue, i have upgrading my flutter version and now the geolocator is working – Dzy Commented Mar 21 at 13:47
4 Answers
Reset to default 2OK, I have face the same problem, i found that in android version 4.6.1 the gradle android property dont have flutter property like this:geolocation_android gradle4.6.1
but in android version 4.6.2,they change to this:geolocation_android gradle4.6.2
and the flutter geolocator auto upgrade to 4.6.2 just like flutter geolocator pubspec.yaml
so in flutter pubspec.yaml, i lock to geolocator_android version to 4.6.1 like project pubspec.yaml
and the gradle not error again
I faced this issue after upgrading Flutter from 3.24.3
and changing the old branch version of my Flutter project. I tested some versions of Geolocator, but none of them worked. I also tried updating my Gradle, but that didn’t work either. I’m not sure of the reason, but I fixed it by upgrading Flutter to the latest version, 3.29.3
After upgrading my Flutter version, the Android Studio debug button keeps getting the same Geolocator error. However, running flutter run
from the command line worked. I tried invalidating caches, but there was no result. Maybe uninstalling and reinstalling could fix it.
I faced this issue; just add it to dependencies and copy the same version in your pubspec.yaml .
dependencies:
geolocator_android: 4.6.1
if you are using flutter sdk : 3.24.5 or fimilar then just downgrade geolocator_android version then it automatically solved
geolocator_android: 4.6.1