解决简单 Flutter 项目中的地理定位器依赖性时出错

问题描述 投票:0回答:1

所以我使用 flutter 和 openweather-api 构建了一个简单的 weather-app。每当我尝试为 Android 设备运行程序(或构建 apk)时,我都会收到以下错误:

* 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)
   
...

在另一个构建修复之后,我还清除了我的

~/.gradle/cahes
文件夹

我认为原因可能是 kotlin 依赖项不匹配,因为我过去为此修改了 build.gradle。这是我的(模块)gradle 文件

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
}


我尝试在网上搜索这个(还有 Chat-GPT,但它已经过时的信息)3 天了,但没有任何效果。如果有人可以提供任何可能的解决方案或引导正确的方向,我们将不胜感激

flutter-dependencies geolocator
1个回答
0
投票

降级地理定位器版本:^7.0.3 或 https://github.com/Baseflow/flutter-geolocator/issues/1441

© www.soinside.com 2019 - 2024. All rights reserved.