flutter duplicate class. trying to use admob

I m trying to use admob, I checked out others's solutions but they don't work for me

output

Launching lib/main.dart on VKY L29 in debug mode...

Running Gradle task 'assembleDebug'...

FAILURE: Build failed with an exception.

 What went wrong:
Execution failed for task ':app:checkDebugDuplicateClasses'.
 1 exception was raised by workers:
  java.lang.RuntimeException: Duplicate class com.google.android.gms.internal.measurement.zzbv found in modules play-services-measurement-17.0.0-runtime.jar (com.google.android.gms:play-services-measurement:17.0.0) and play-services-measurement-base-17.1.0-runtime.jar (com.google.android.gms:play-services-measurement-base:17.1.0)
  Duplicate class com.google.android.gms.internal.measurement.zzbw found in modules play-services-measurement-17.0.0-runtime.jar (com.google.android.gms:play-services-measurement:17.0.0) and play-services-measurement-base-17.1.0-runtime.jar (com.google.android.gms:play-services-measurement-base:17.1.0)
  Duplicate class com.google.android.gms.internal.measurement.zzdf found in modules play-services-measurement-base-17.1.0-runtime.jar (com.google.android.gms:play-services-measurement-base:17.1.0) and play-services-measurement-impl-17.0.0-runtime.jar (com.google.android.gms:play-services-measurement-impl:17.0.0)
  Duplicate class com.google.android.gms.internal.measurement.zzdg found in modules play-services-measurement-base-17.1.0-runtime.jar (com.google.android.gms:play-services-measurement-base:17.1.0) and play-services-measurement-impl-17.0.0-runtime.jar (com.google.android.gms:play-services-measurement-impl:17.0.0)
  Duplicate class com.google.android.gms.internal.measurement.zzdh found in modules play-services-measurement-base-17.1.0-runtime.jar (com.google.android.gms:play-services-measurement-base:17.1.0) and play-services-measurement-impl-17.0.0-runtime.jar (com.google.android.gms:play-services-measurement-impl:17.0.0)
  Duplicate class com.google.android.gms.internal.measurement.zzdi found in modules play-services-measurement-base-17.1.0-runtime.jar (com.google.android.gms:play-services-measurement-base:17.1.0) and play-services-measurement-impl-17.0.0-runtime.jar (com.google.android.gms:play-services-measurement-impl:17.0.0)
  Duplicate class com.google.android.gms.internal.measurement.zzdj found in modules play-services-measurement-base-17.1.0-runtime.jar (com.google.android.gms:play-services-measurement-base:17.1.0) and play-services-measurement-impl-17.0.0-runtime.jar (com.google.android.gms:play-services-measurement-impl:17.0.0)
  Duplicate class com.google.android.gms.internal.measurement.zzdk found in modules play-services-measurement-base-17.1.0-runtime.jar (com.google.android.gms:play-services-measurement-base:17.1.0) and play-services-measurement-impl-17.0.0-runtime.jar (com.google.android.gms:play-services-measurement-impl:17.0.0)
  Duplicate class com.google.android.gms.internal.measurement.zzdl found in modules play-services-measurement-base-17.1.0-runtime.jar (com.google.android.gms:play-services-measurement-base:17.1.0) and play-services-measurement-impl-17.0.0-runtime.jar (com.google.android.gms:play-services-measurement-impl:17.0.0)
  Duplicate class com.google.android.gms.internal.measurement.zzdm found in modules play-services-measurement-base-17.1.0-runtime.jar (com.google.android.gms:play-services-measurement-base:17.1.0) and play-services-measurement-impl-17.0.0-runtime.jar (com.google.android.gms:play-services-measurement-impl:17.0.0)
  Duplicate class com.google.android.gms.internal.measurement.zzdn found in modules play-services-measurement-base-17.1.0-runtime.jar (com.google.android.gms:play-services-measurement-base:17.1.0) and play-services-measurement-impl-17.0.0-runtime.jar (com.google.android.gms:play-services-measurement-impl:17.0.0)
  Duplicate class com.google.android.gms.internal.measurement.zzdo found in modules play-services-measurement-base-17.1.0-runtime.jar (com.google.android.gms:play-services-measurement-base:17.1.0) and play-services-measurement-impl-17.0.0-runtime.jar (com.google.android.gms:play-services-measurement-impl:17.0.0)
  Duplicate class com.google.android.gms.internal.measurement.zzdp found in modules play-services-measurement-base-17.1.0-runtime.jar (com.google.android

my project level build.gradle

buildscript {
    ext.kotlin_version = '1.3.50'
    repositories {
        google()
        jcenter()
    }

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

allprojects {
    repositories {
        google()
        jcenter()
    }
}

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

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

my app level build.gradle

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
    throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
    compileSdkVersion 28

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.example.logic_game_app"
        minSdkVersion 16
        targetSdkVersion 28
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig signingConfigs.debug
        }
    }
}

flutter {
    source '../..'
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
    implementation 'com.google.android.gms:play-services-ads:18.3.0'
}

android manifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.logic_game_app">
    <!-- io.flutter.app.FlutterApplication is an android.app.Application that
         calls FlutterMain.startInitialization(this); in its onCreate method.
         In most cases you can leave this as-is, but you if you want to provide
         additional functionality it is fine to subclass or reimplement
         FlutterApplication and put your custom class here. -->
    <application
        android:name="io.flutter.app.FlutterApplication"
        android:label="logic_game_app"
        android:icon="@mipmap/ic_launcher">

        <meta-data
            android:name="com.google.android.gms.ads.APPLICATION_ID"
            android:value="ca-app-xxxxxxxxxxxxxxxxxxxxxxxxxxxx"/>
        <activity
            android:name=".MainActivity"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
        <!-- Don't delete the meta-data below.
             This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
    </application>
</manifest>

Go to the documentation to learn how to Fix dependency resolution errors.

  • 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 11s Finished with error: Gradle task assembleDebug failed with exit code 1