我尝试在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/