Error with Google Maps Flutter in Android Studio

Viewed 442

I try to add google maps on flutter, I added the following dependence:

dependencies:
 google_maps_flutter: ^0.5.17

and its respective api key in android and ios.

But when running the project it marks the following:

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

and try to add the dependencies manually in buil.gradle

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

and this in build.gradle in project level

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

but still with the same.

1 Answers

You probably have to migrate your project to AndroidX. I had a similar issue in my project.

Open you Android folder in Android studio, go to File -> Sync Project With Gradle Files and then Refactor -> Migrate to AndroidX

Related