8

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:

app\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 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'

android\build.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
}
Sanket Kumar
  • 123
  • 1
  • 5

6 Answers6

21

Fixed it by adding below line in /android/app/build.gradle

dependencies {
    ....
    implementation ('com.google.android.exoplayer:exoplayer:2.17.0')
}
esentis
  • 4,190
  • 2
  • 12
  • 28
  • Adding this line solves the problem but in this case I have errors in Flutter with `assets_audio_player` package. – shuster Apr 12 '22 at 08:22
  • 2
    Hey @shuster that's unfortunate. Check this issue https://github.com/flutter/flutter/issues/100948 it may assist you. – esentis Apr 12 '22 at 08:31
  • It's related my issue, thanks. But still it didn't solve my problem. I will move to another package. – shuster Apr 12 '22 at 10:21
3
  • 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'
    
Codemaker2015
  • 12,190
  • 6
  • 97
  • 81
2

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

lordkyle
  • 29
  • 3
  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jul 29 '22 at 10:23
0

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

  • flutter clean
  • flutter pub cache clean
  • flutter pub get
0

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

Ahmad Raza
  • 758
  • 7
  • 26
RuchDi
  • 250
  • 3
  • 14
0

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

Murat Kurbanov
  • 589
  • 7
  • 11