skip to Main Content

Having this error while i was trying to run my flutter application:

Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:app:checkDebugDuplicateClasses’.

A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
Duplicate class com.google.android.exoplayer2.ui.DownloadNotificationHelper found in modules jetified-exoplayer-core-2.17.0-runtime (com.google.android.exoplayer:exoplayer-core:2.17.0) and jetified-exoplayer-ui-2.15.0-runtime (com.google.android.exoplayer:exoplayer-ui:2.15.0)

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.

BUILD FAILED in 1m 47s
Exception: Gradle task assembleDebug failed with exit code 1

How can I fix this error.?
Below are my build.gradle files:

appbuild.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 flutter.compileSdkVersion

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

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

    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 '../..'
}


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

androidbuild.gradle:

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

    dependencies {
        classpath 'com.android.tools.build:gradle:4.1.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.3.10'
    }
}

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
}

6

Answers


  1. I had the same issue, try to clean all caches and get dependencies again:

    • flutter clean
    • flutter pub cache clean
    • flutter pub get
    Login or Signup to reply.
  2. Fixed it by adding below line in /android/app/build.gradle

    dependencies {
        ....
        implementation ('com.google.android.exoplayer:exoplayer:2.17.0')
    }
    
    Login or Signup to reply.
    • Try to reinstall the flutter libraries using the following commands,

      flutter clean
      flutter pub cache clean
      flutter pub get
      
    • Add the following implementation on the app-level build.gradle file

      dependencies {
         ....
         implementation ('com.google.android.exoplayer:exoplayer:2.17.0')
      }
      
    • Ensure that the androidX and Jetifier support is enabled and mentioned in the gradle.properties file. If not, add the following entries to the gradle.properties file.

      android.useAndroidX=true
      android.enableJetifier=true 
      
    • You can implement the following dependency in the build.gradle file if none of the above steps resolved your issue.

      implementation 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava'
      
    Login or Signup to reply.
  3. if you use EXPO check if you have installed any expo module also using exoplayer to avoid version conflict.

    In my I was using expo-av and when I wanted to add react-native-track-player I had the same problem

    Login or Signup to reply.
  4. You need to update these two files

    build.gradle file

    ...
        dependencies {
            classpath 'com.android.tools.build:gradle:4.1.0' -- update 4.1.0 to 7.1.1
    ...
    }
    

    gradle-wrapper.properties file

    ...
    distributionUrl=https://services.gradle.org/distributions/gradle-6.5-all.zip  -- update 6.5 to 7.2
    
    
    Login or Signup to reply.
  5. To solve this issue, you have to make sure your gradle in your build.gradle and the gradle in your android/gradle/wrapper/gradle-wrapper.properties are the same version.

    distributionUrl=https://services.gradle.org/distributions/gradle-7.5.1-all.zip
    

    and

    android/build.gradle

    dependencies { classpath 'com.android.tools.build:gradle:7.3.1' ... }
    

    find last gradle version
    https://gradle.org/releases/

    find last dependency version
    https://mvnrepository.com/artifact/com.android.tools.build/gradle?repo=google

    After apply these changes, if you use useProguard, so you should face issue like:
    useProguard not found or etc
    The useProguard option was removed since gradle 7.0.0, so you should delete this line in your_project/android/app/build.gradle

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search