android - Android Studio 中的 Google map Flutter 出现错误

标签 android gradle flutter

我尝试在flutter上添加谷歌地图,我添加了以下依赖:

dependencies:
 google_maps_flutter: ^0.5.17

及其在 android 和 ios 中各自的 api key 。

但是运行项目时它会标记以下内容:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:preDebugBuild'.
> Android dependency 'com.google.android.gms:play-services-tasks' has different version for the compile (15.0.1) and runtime (16.0.1) classpath. You should manually set the same version via DependencyResolution

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 4s
Finished with error: Gradle task assembleDebug failed with exit code 1

并尝试在 build.gradle 中手动添加依赖项

dependencies {
        classpath 'com.google.gms:google-services:4.2.0'
    }

这在项目级别的 build.gradle 中

apply plugin: 'com.google.gms.google-services'

但还是一样。

最佳答案

您可能必须将项目迁移到 AndroidX。我的项目中也遇到了类似的问题。

在 Android studio 中打开 Android 文件夹,转到文件 -> 将项目与 Gradle 文件同步,然后重构 -> 迁移到 AndroidX

关于android - Android Studio 中的 Google map Flutter 出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56658606/

相关文章:

flutter - 未处理的异常 : Content size below specified contentLength. 已写入 206 字节但预期为 375482。#228

Flutter-GestureDetector 不适用于堆栈中的容器

java - 试图找到 CH34xAndroidDriver.isConnected() 何时变为真

android - 成功安装Gradle后,Android Release APK崩溃

android - 在 android 中清除 SurfaceView

scala - Buildr vs Gradle,优缺点?

java - Gradle::在sourceSets中设置outputDir时找不到参数main()作为参数

flutter - 我如何将字符串类型 "Timestamp(seconds=1621176915, nanoseconds=276147000)"转换为实际时间戳类型?

android - 如何将位置类型 ArrayList 从 android 中的 MainActivity 传递给 MapsActivity?

Android Volley POST 参数