Home > Enterprise >  Error occurred after adding dependencies for Google maps in flutter
Error occurred after adding dependencies for Google maps in flutter

Time:07-23

Showed this error when I debug the project

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugMainManifest'.
> Manifest merger failed : uses-sdk:minSdkVersion 16 cannot be smaller than version 20 declared in library [:google_maps_flutter] C:\Users\HOME\Mini_Project\FRONTEND\waste_mgmt_app\build\google_maps_flutter\intermediates\merged_manifest\debug\AndroidManifest.xml as the library might be using APIs not available in 16
    Suggestion: use a compatible library with a minSdk of at most 16,
        or increase this project's minSdk version to at least 20,
        or use tools:overrideLibrary="io.flutter.plugins.googlemaps" to force usage (may lead to runtime failures)

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

So i add the flutter fix which is shown with the error in terminal.

  ─ Flutter Fix ─────────────────────────────────────────────────────────────────────────────────┐
│ The plugin google_maps_flutter requires a higher Android SDK version.                         │
│ Fix this issue by adding the following to the file                                            │
│ C:\Users\HOME\Mini_Project\FRONTEND\waste_mgmt_app\android\app\build.gradle:                  │
│ android {                                                                                     │
│   defaultConfig {                                                                             │
│     minSdkVersion 20                                                                          │
│   }                                                                                           │
│ }                                                                                             │
│                                                                                               │
│ Note that your app won't be available to users running Android SDKs below 20.                 │
│ Alternatively, try to find a version of this plugin that supports these lower versions of the │
│ Android SDK.                                                                                  │
│ For more information, see:                                                                    │
│ https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration                 │
└───────────────────────────────────────────────────────────────────────────────────────────────┘

After adding this i'm getting another error

FAILURE: Build failed with an exception.

  • Where: Build file 'C:\Users\HOME\Mini_Project\FRONTEND\waste_mgmt_app\android\build.gradle' line: 14

  • What went wrong: A problem occurred evaluating root project 'android'.

Could not find method android() for arguments [build_7r5vfi6enrsrbqp9mx3wf0jb$_run_closure1@1e4e59f9] on root project 'android' of type org.gradle.api.Project.

  • 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.

BUILD FAILED in 6s

This is my build.gradle

 buildscript {
    ext.kotlin_version = '1.6.10'
    repositories {
        google()
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:7.1.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

   android {                                                                                     
   defaultConfig {                                                                             
     minSdkVersion 20                                                                          
   }                                                                                           
 } 

allprojects {
    repositories {
        google()
        mavenCentral()
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

How can i remove the errors and build a google map page?

CodePudding user response:

you put following lines in wrong gradle file

android {                                                                                     
   defaultConfig {                                                                             
     minSdkVersion 20                                                                          
   }                                                                                           
 } 

put above lines into app gradle i.e android\app\build.gradle, also change your sdk version too

  • Related