Home > Blockchain >  Error while using Google Maps in Flutter App
Error while using Google Maps in Flutter App

Time:11-14

I try to use google-maps inside my flutter app but, I am getting this error every time I try to debug my code.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Could not find play-services-maps-17.0.0.aar (com.google.android.gms:play-services-maps:17.0.0).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/com/google/android/gms/play-services-maps/17.0.0/play-services-maps-17.0.0.aar

* 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 39s
Exception: Gradle task assembleDebug failed with exit code 1

CodePudding user response:

Please go to file -> android/app/build.gradle

and edit minSdkVersion from 16 to 21

    defaultConfig {
    // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
    applicationId "com.example.google_maps"
    minSdkVersion 21
    targetSdkVersion 30
    versionCode flutterVersionCode.toInteger()
    versionName flutterVersionName
}

CodePudding user response:

According to it's document you should set the minSdkVersion in android/app/build.gradle:

android {
    defaultConfig {
        minSdkVersion 20
    }
}

Also add this code in the main file :

void main() {
  if (defaultTargetPlatform == TargetPlatform.android) {
    AndroidGoogleMapsFlutter.useAndroidViewSurface = true;
  }
  runApp(MyApp());
}

Configuartion link : https://pub.dev/packages/google_maps_flutter#android

Note: Please, check your Internet connection and, try a VPN!

  • Related