Error Resolving geolocator dependency in a Simple Flutter Project

51 Views Asked by At

So I have build a simple weather-app using flutter and openweather-api. Whenever I try to run program for a android device (or build a apk) I Get Following error:

* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all files for configuration ':classpath'.
   > Could not find org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.1.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin/1.7.1/kotlin-gradle-plugin-1.7.1.pom
       - https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin/1.7.1/kotlin-gradle-plugin-1.7.1.pom

    ~/Desktop/my_weather   main +4 !1  
flutter build apk                                                                                                            ✔  07:45:57 AM 


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':geolocator_android:generateReleaseRFile'.
> Could not resolve all files for configuration ':geolocator_android:releaseCompileClasspath'.
   > Failed to transform play-services-location-21.1.0.aar (com.google.android.gms:play-services-location:21.1.0) to match attributes {artifactType=android-symbol-with-package-name, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-api}.
      > Execution failed for ExtractAarTransform: /home/prakhar/.gradle/caches/transforms-3/583f6a7ab8378e7f6824bb095b70b307/transformed/jetified-play-services-location-21.1.0.aar.
         > /home/prakhar/.gradle/caches/transforms-3/583f6a7ab8378e7f6824bb095b70b307/transformed/jetified-play-services-location-21.1.0.aar (No such file or directory)
   
...

I have also cleared my ~/.gradle/cahes folder following another build fix

I figured the reason could have been kotlin dependency mismatch as i have modified build.gradle for that in past. here is my (module) gradle file android/build.gradle.

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

buildscript {
    ext.kotlin_version = '1.5.20'
    repositories {
        google()
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:4.1.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}


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

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


I tried searching this online (and also Chat-GPT but it has outdated information) for 3 days now but nothing worked. If someone can provide any possible solution or lead in right direction, anything would be appreciated

1

There are 1 best solutions below

1
ajbg On

downgrade for version geolocator: ^7.0.3 or https://github.com/Baseflow/flutter-geolocator/issues/1441