Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Flutter : A problem occurred evaluating project ':geolocator_android' #1665

Closed
3 of 8 tasks
Dzikry123 opened this issue Mar 21, 2025 · 4 comments
Closed
3 of 8 tasks
Labels
P2 Important issues not at the top of the work list. platform: android Issue is related to the Android platform. status: needs more info We need more information before we can continue work on this issue.

Comments

@Dzikry123
Copy link

Please check the following before submitting a new issue.

Please select for which platform(s) you need help

  • Android
  • iOS
  • Linux
  • macOS
  • Web
  • Windows

Your question

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 org.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.com/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.com/training/package-visibility and
         https://developer.android.com/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.com/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 "org.jetbrains.kotlin.android" version "1.9.0" apply false
}

include ":app"

pubspec.yaml :

version: 1.0.0+1

environment:
  sdk: ^3.5.4


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

Version

^14.2.6

@faiyazz-shaikh

This comment has been minimized.

@mvanbeusekom

This comment has been minimized.

@mvanbeusekom
Copy link
Member

Hi @Dzikry123,

Which version of Flutter are you using? Could you maybe include the output of the flutter doctor -v command?

Version 4.6.2 of the geolocator_android package has been updated to depend on version 3.27 or higher of the Flutter SDK, possibly you are using an older version of Flutter causing this issue.

@mvanbeusekom mvanbeusekom added status: needs more info We need more information before we can continue work on this issue. platform: android Issue is related to the Android platform. P2 Important issues not at the top of the work list. labels Mar 21, 2025
@Dzikry123
Copy link
Author

heloo @mvanbeusekom thank you for the help, it seems that my flutter version is the issue, i have upgrading my flutter version and now the geolocator is working, thank you

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
P2 Important issues not at the top of the work list. platform: android Issue is related to the Android platform. status: needs more info We need more information before we can continue work on this issue.
Projects
None yet
Development

No branches or pull requests

3 participants