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.
- Get more help at https://help.gradle.org
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
I had the same issue, try to clean all caches and get dependencies again:
flutter clean
flutter pub cache clean
flutter pub get
Fixed it by adding below line in
/android/app/build.gradle
Try to reinstall the flutter libraries using the following commands,
Add the following implementation on the app-level
build.gradle
fileEnsure that the
androidX
andJetifier
support is enabled and mentioned in thegradle.properties
file. If not, add the following entries to thegradle.properties
file.You can implement the following dependency in the
build.gradle
file if none of the above steps resolved your issue.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
You need to update these two files
build.gradle file
gradle-wrapper.properties file
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.
and
android/build.gradle
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