Baseflow / flutter-geolocator

Android and iOS Geolocation plugin for Flutter
https://baseflow.com/
MIT License
1.22k stars 626 forks source link

[Bug]: Requires newer version of Kotlin Gradle Plugin #1517

Open anmol-me opened 1 month ago

anmol-me commented 1 month ago

Please check the following before submitting a new issue.

Please select affected platform(s)

Steps to reproduce

  1. Install the dependency.
  2. Run in Android emulator without even importing the package.

Expected results

Should run without any errors.

Actual results

App doesn't run

Code sample

android\build

allprojects {
    repositories {
        google()
        mavenCentral()
    }
}

rootProject.buildDir = "../build"
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(":app")
}

tasks.register("clean", Delete) {
    delete rootProject.buildDir
}

app\build

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"
}

def localProperties = new Properties()
def localPropertiesFile = rootProject.file("local.properties")
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader("UTF-8") { reader ->
        localProperties.load(reader)
    }
}

def flutterVersionCode = localProperties.getProperty("flutter.versionCode")
if (flutterVersionCode == null) {
    flutterVersionCode = "1"
}

def flutterVersionName = localProperties.getProperty("flutter.versionName")
if (flutterVersionName == null) {
    flutterVersionName = "1.0"
}

android {
    namespace = "com.anisingh.travel_project"
    compileSdk = flutter.compileSdkVersion
    ndkVersion = flutter.ndkVersion

    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId = "com.anisingh.travel_project"
        // You can update the following values to match your application needs.
        // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
        minSdk = 28
        targetSdk = flutter.targetSdkVersion
        versionCode = flutterVersionCode.toInteger()
        versionName = flutterVersionName
    }

    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 = "../.."
}

Version

12.0.0

Flutter Doctor output

e: C:/Users/Anmol/.gradle/caches/transforms-3/362b2d499a05b04c0c112f7a304aa7e2/transformed/jetified-kotlin-stdlib-common-1.9.0.jar!/META-INF/kotlin-stdlib-common.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.7.1. e: C:/Users/Anmol/.gradle/caches/transforms-3/a986ff86be3aa69fb7fd119d17309b08/transformed/jetified-kotlin-stdlib-1.9.0.jar!/META-INF/kotlin-stdlib-jdk7.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.7.1. e: C:/Users/Anmol/.gradle/caches/transforms-3/a986ff86be3aa69fb7fd119d17309b08/transformed/jetified-kotlin-stdlib-1.9.0.jar!/META-INF/kotlin-stdlib-jdk8.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.7.1. e: C:/Users/Anmol/.gradle/caches/transforms-3/a986ff86be3aa69fb7fd119d17309b08/transformed/jetified-kotlin-stdlib-1.9.0.jar!/META-INF/kotlin-stdlib.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.7.1.

FAILURE: Build failed with an exception.

BUILD FAILED in 7s

┌─ Flutter Fix ──────────────────────────────────────────────────────────────────────────────┐ │ [!] Your project requires a newer version of the Kotlin Gradle plugin. │ │ Find the latest version on https://kotlinlang.org/docs/releases.html#release-details, then │ │ update C:\Users\Anmol\FlutterProjects\travel_project\android\build.gradle: │ │ ext.kotlin_version = '' │ └────────────────────────────────────────────────────────────────────────────────────────────┘ Error: Gradle task assembleDebug failed with exit code 1

FlutteriPOP commented 1 month ago

i am also facing the same issue

rminkler1 commented 1 month ago

This is related to geolocator_android 4.6.0 A workaround is to add 4.5.5 to your dependencies until 4.6.0 gets fixed.

anmol-me commented 1 month ago

This is related to geolocator_android 4.6.0 A workaround is to add 4.5.5 to your dependencies until 4.6.0 gets fixed.

Thanks @rminkler1

  1. Add the following to dependencies: geolocator: ^12.0.0 geolocator_android: 4.5.5

    1. Run the following commands: flutter clean flutter pub get
FlutteriPOP commented 1 month ago

Thanks @rminkler1 Now Its Working Perfectolly

Muhammadurasheed commented 1 month ago

Wow! It works 🤗 You just saved the day. You won't believe that I've been battling with the error for days

rminkler1 commented 1 month ago

Wow! It works 🤗 You just saved the day. You won't believe that I've been battling with the error for days

I do believe you, because I was also battling this for days. I updated Flutter and I thought I broke something with my Flutter install. It took me almost a week to figure out it was this package.

ravikumarbigwings commented 1 month ago

This is related to geolocator_android 4.6.0 A workaround is to add 4.5.5 to your dependencies until 4.6.0 gets fixed.

thank you bro

Meizzosama commented 1 month ago

@anmol-me @rminkler1 what version to use for location package?

rminkler1 commented 1 month ago

geolocator: ^12.0.0 geolocator_android: 4.5.5

Meizzosama commented 1 month ago

@rminkler1 sir i am asking for location package not for geolocator..

rminkler1 commented 1 month ago

@rminkler1 sir i am asking for location package not for geolocator..

Then I'm afraid I don't understand what you are asking. Geolocator is the package that gets the location of the device. This thread is about a bug in the Android implementation of that package and how to workaround that bug until it is fixed. I've only used geolocator once and ran into this bug, so I'm afraid I can't help beyond this.

anmol-me commented 1 month ago

@Meizzosama Hey, please search if you can find a similar issue with the author of location package. If you can't find it, please raise the issue with the author.

Here is a link to help you get started: https://github.com/Lyokone/flutterlocation/issues

Meizzosama commented 1 month ago

@anmol-me Brother i found the solution. i-e, I haven't updated the kotlin version on file "settings.gradle" that's why it was giving me that error, but later on i fixed it. Thanks a bunch for your reply :)

saumon commented 1 month ago

@rminkler1 thanks, switching to geolocator_android: 4.5.5 saved me hours of researches....

aliwaseem27 commented 1 month ago

Facing the same problem, after searching for days found out that geolocator causing it. hope it will be fixed soon.

Pieter-Uys commented 4 weeks ago

geolocator: ^12.0.0 geolocator_android: 4.5.5

So for some reason when you add

geolocator_android: 4.5.5 it fixes the issue and then you can remove geolocator_android: 4.5.5 afterwards and geolocator: ^12.0.0 will work without it.

cnLiuMing commented 4 weeks ago
  1. geolocator_android

geolocator: ^12.0.0 still gives an error

rminkler1 commented 4 weeks ago
  1. geolocator_android

geolocator: ^12.0.0 still gives an error

Add the following two dependencies: geolocator: ^12.0.0 geolocator_android: 4.5.5

Run the following commands: flutter clean flutter pub get

rminkler1 commented 4 weeks ago

geolocator: ^12.0.0 geolocator_android: 4.5.5

So for some reason when you add

geolocator_android: 4.5.5 it fixes the issue and then you can remove geolocator_android: 4.5.5 afterwards and geolocator: ^12.0.0 will work without it.

That might happen if you don't re-run pub get. I suspect if you run pub get again, it breaks again.

jsqi2009 commented 4 days ago

Thanks @rminkler1, fixed my issue