I want to import Coil library in my project. I did it like below:
android{
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
kotlinOptions {
jvmTarget = "1.8"
}
}
dependencies {
implementation("io.coil-kt:coil:0.8.0")
}
The project will sync successfully, But When I want to run the application I 'll face with this error:
Duplicate class androidx.appcompat.content.res.AppCompatResources found in modules classes.jar (androidx.appcompat:appcompat-resources:1.1.0) and classes.jar (androidx.appcompat:appcompat:1.0.0)
Duplicate class androidx.appcompat.content.res.AppCompatResources$ColorStateListCacheEntry found in modules classes.jar (androidx.appcompat:appcompat-resources:1.1.0) and classes.jar (androidx.appcompat:appcompat:1.0.0)
Duplicate class androidx.appcompat.graphics.drawable.AnimatedStateListDrawableCompat found in modules classes.jar (androidx.appcompat:appcompat-resources:1.1.0) and classes.jar (androidx.appcompat:appcompat:1.0.0)
Duplicate class androidx.appcompat.graphics.drawable.AnimatedStateListDrawableCompat$1 found in modules classes.jar (androidx.appcompat:appcompat-resources:1.1.0) and classes.jar (androidx.appcompat:appcompat:1.0.0)
My app is converted to the AndroidX before. Also, my targetSdkVersion = 29 and minSdkVersion = 17
You need appcompat library
implementation "androidx.appcompat:appcompat:1.1.0"
You need appcompat library
implementation "androidx.appcompat:appcompat:1.1.0"
This is correct but you also need to
Go to gradle.properties and add
android.enableJetifier=true
android.useAndroidX=true
I had the same problem and I think it's related to the last version of Androidx.
Anyway you probably have one dependency using an old version of androidx.appcompat. Setting enableJetifier=true will force the use of the most recent one.
For info I'm using Coil on version
implementation "io.coil-kt:coil:0.10.0"
Related
im trying to implement the 'com.github.barteksc:android-pdf-viewer:2.8.2' into my project and i am able to sync the gradle files but when i try to start the app it gives me this error
Duplicate class android.support.v4.app.INotificationSideChannel found in modules core-1.5.0-
runtime (androidx.core:core:1.5.0) and support-compat-25.3.1-runtime (com.android.support:support-compat:25.3.1)
Duplicate class android.support.v4.app.INotificationSideChannel$Stub found in modules core-1.5.0-runtime (androidx.core:core:1.5.0) and support-compat-25.3.1-runtime (com.android.support:support-compat:25.3.1)
Duplicate class android.support.v4.app.INotificationSideChannel$Stub$Proxy found in modules core-1.5.0-runtime (androidx.core:core:1.5.0) and support-compat-25.3.1-runtime (com.android.support:support-compat:25.3.1)
Duplicate class android.support.v4.os.IResultReceiver found in modules core-1.5.0-runtime (androidx.core:core:1.5.0) and support-compat-25.3.1-runtime (com.android.support:support-compat:25.3.1)
Duplicate class android.support.v4.os.IResultReceiver$Stub found in modules core-1.5.0-runtime (androidx.core:core:1.5.0) and support-compat-25.3.1-runtime (com.android.support:support-compat:25.3.1)
Duplicate class android.support.v4.os.IResultReceiver$Stub$Proxy found in modules core-1.5.0-runtime (androidx.core:core:1.5.0) and support-compat-25.3.1-runtime (com.android.support:support-compat:25.3.1)
Duplicate class android.support.v4.os.ResultReceiver found in modules core-1.5.0-runtime (androidx.core:core:1.5.0) and support-compat-25.3.1-runtime (com.android.support:support-compat:25.3.1)
Duplicate class android.support.v4.os.ResultReceiver$1 found in modules core-1.5.0-runtime (androidx.core:core:1.5.0) and support-compat-25.3.1-runtime (com.android.support:support-compat:25.3.1)
Duplicate class android.support.v4.os.ResultReceiver$MyResultReceiver found in modules core-1.5.0-runtime (androidx.core:core:1.5.0) and support-compat-25.3.1-runtime (com.android.support:support-compat:25.3.1)
Duplicate class android.support.v4.os.ResultReceiver$MyRunnable found in modules core-1.5.0-runtime (androidx.core:core:1.5.0) and support-compat-25.3.1-runtime (com.android.support:support-compat:25.3.1)
Go to the documentation to learn how to Fix dependency resolution errors
i do not get why i will post my build.gradle below
plugins {
id 'com.android.application'
id 'kotlin-android'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.jenson.resumeapp"
minSdkVersion 19
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.5.0'
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
i do not seem to find anything on this that works?
Add these lines in gradle.properties file
android.useAndroidX = true
android.enableJetifier = true
I was running into the same issue when I was implementing :
com.github.shts:StoriesProgressView:3.0.0
The problem, in my case at least, was that StoriesProgessView dependency was retrieving the same class from com.android.support:support-compat which is now already present in the androidx core package, causing the conflict to rise up.
This is how I went about it:
By checking out the Dependency tree, I found out that the StoriesProgressView was bringing in these dependencies, to remove those dependencies, I added the exlusion rule to the dependency like so:
implementation ('com.github.shts:StoriesProgressView:3.0.0') {
exclude group: "com.android.support", module: "support-compat"
exclude group: "com.android.support", module: "support-media-compat"
}
this stopped pulling the classes from the old package.
In your case though, there doesn't seem to be any third-party dependency so probably following Malik Ali's answer should suffice. If it doesn't, give this one a go!
Add this line in gradle.properties
android.enableJetifier = true
I am trying to build an app with openCV and Firebase ML Kit. But I get the following error while building project:
Duplicate class com.google.android.gms.internal.vision.zze found in modules jetified-play-services-vision-20.0.0-runtime.jar (com.google.android.gms:play-services-vision:20.0.0) and jetified-play-services-vision-common-19.1.0-runtime.jar (com.google.android.gms:play-services-vision-common:19.1.0)
Duplicate class com.google.android.gms.internal.vision.zzf found in modules jetified-play-services-vision-20.0.0-runtime.jar (com.google.android.gms:play-services-vision:20.0.0) and jetified-play-services-vision-common-19.1.0-runtime.jar (com.google.android.gms:play-services-vision-common:19.1.0)
Duplicate class com.google.android.gms.internal.vision.zzg found in modules jetified-play-services-vision-20.0.0-runtime.jar (com.google.android.gms:play-services-vision:20.0.0) and jetified-play-services-vision-common-19.1.0-runtime.jar (com.google.android.gms:play-services-vision-common:19.1.0)
Duplicate class com.google.android.gms.internal.vision.zzh found in modules jetified-play-services-vision-20.0.0-runtime.jar (com.google.android.gms:play-services-vision:20.0.0) and jetified-play-services-vision-common-19.1.0-runtime.jar (com.google.android.gms:play-services-vision-common:19.1.0)
Duplicate class com.google.android.gms.internal.vision.zzi found in modules jetified-play-services-vision-20.0.0-runtime.jar (com.google.android.gms:play-services-vision:20.0.0) and jetified-play-services-vision-common-19.1.0-runtime.jar (com.google.android.gms:play-services-vision-common:19.1.0)
Duplicate class com.google.android.gms.internal.vision.zzv found in modules jetified-play-services-vision-20.0.0-runtime.jar (com.google.android.gms:play-services-vision:20.0.0) and jetified-play-services-vision-common-19.1.0-runtime.jar (com.google.android.gms:play-services-vision-common:19.1.0)
Duplicate class com.google.android.gms.internal.vision.zzw found in modules jetified-play-services-vision-20.0.0-runtime.jar (com.google.android.gms:play-services-vision:20.0.0) and jetified-play-services-vision-common-19.1.0-runtime.jar (com.google.android.gms:play-services-vision-common:19.1.0)
Go to the documentation to learn how to Fix dependency resolution errors.
I have tried searching exact same error and didn't get anything, then I searched duplicate class issues, there wasn't a certain way of solving the problem, everyone shared their experience and neither of them worked for me.
This is my build.gradle file:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 30
buildToolsVersion "30.0.2"
defaultConfig {
applicationId "com.example.cameraactivity"
minSdkVersion 21
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.1'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
implementation 'com.google.firebase:firebase-ml-vision:24.1.0'
implementation project(path: ':sdk')
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
It's all about this line:
implementation 'com.google.firebase:firebase-ml-vision:24.1.0'
When I comment this line, it doesn't give errors when I build project (I haven't added functionality yet).
Thanks in advance
Add the following in build.gradle:Module
implementation 'com.google.android.gms:play-services-vision:20.0.0'
implementation 'com.google.firebase:firebase-ml-vision:24.0.3'
implementation 'com.google.firebase:firebase-ml-vision-barcode-model:16.1.1'
And in build.gradle:Project
classpath 'com.google.gms:google-services:4.3.3'
In buildscript-->dependencies.
I had the same issue with the 24.1.0 version of firebase-ml-vision.
Here is the official resolution solution :
Firebase Release Note MLKIT Self Serve Fixes
So I had to add a dependency to play-services-vision that I did not need anymore before :
implementation 'com.google.android.gms:play-services-vision:20.1.1'
I hope that they will fix it in the next versions
Alternatively and preferably, you should move to the new ML Kit SDK which we launched early June. The on-device APIs are considered deprecated in Firebase ML and updates / improvements are only available in the new SDK. To help with the switch, migration guides can be found here.
I have same issue,if you are using firebase dependencies update following to latest version in app/build.gradle see attached process
dependencies {
implementation platform('com.google.firebase:firebase-bom:29.0.0')
}
Get the latest version via the documentation
https://firebase.google.com/support/release-notes/android
We were facing a similar issue. I am going to add some steps here based on which hopefully someone else who faces this issue can later sort it out themselves.
Our issue was,
Execution failed for task ':app:checkStagingReleaseDuplicateClasses'.
> 1 exception was raised by workers: java.lang.RuntimeException: Duplicate class com.google.android.gms.internal.vision.zzbl found in modules play-services-vision-common-19.1.3-runtime.jar (com.google.android.gms:play-services-vision-common:19.1.3) and play-services-vision-face-contour-internal-16.0.0-runtime.jar (com.google.android.gms:play-services-vision-face-contour-internal:16.0.0)
We tried a lot of things, including steps mentioned here in these set of answers, but nothing worked. After a lot of brute forcing, and mind bending decryption of errors, we did this.
The error was simple, something was showing up in 2 places. Both places were not implemented anywhere in our build.gradle. So it was obviously coming from the group in which the module is placed, in our case com.google.android.gms. So, first we checked what's the version we have implemented for gms, only to realise nothing wrong there. Though we did play around a bit by upgrading and downgrading it, nothing really happened.
So we thought, why not just check where else in the app are one of the duplicates being implemented, only to realise, we have installed react-native-camera, which uses play-services-vision and has it implemented in it's own build.gradle. So now, a bulb went off in our head, we have implemented react-native-camera in our own build.gradle too. Like so
implementation project(':react-native-camera'). Why not make it stop trying to implement play-services-vision-face-contour-internal from our end?
Thus coming to the solution like so,
implementation (project(':react-native-camera')) {
exclude module: 'play-services-vision-face-contour-internal'
}
By doing this, the duplicate error stopped showing and we could continue with our development in peace.
I know there's not a lot of technical knowledge here, this is here just so someone could also look into something like this when they face something like this. I don't know if that made sense
I'm using grpc with protobuf lite in android implementation. but protobuf lite doesn't have google time stamp, and my protos has import "google/protobuf/timestamp.proto". so i added implementation 'com.google.protobuf:protobuf-java:3.7.1' to gradle that contains google time stamp. but after that code compilaition has errors. such as :Duplicate class com.google.protobuf.AbstractMessageLite found in modules protobuf-java-3.7.1.jar (com.google.protobuf:protobuf-java:3.7.1) and protobuf-lite-3.0.1.jar (com.google.protobuf:protobuf-lite:3.0.1).
any idea to fix this would be appreciated.
apply plugin: 'com.android.application'
apply plugin: 'com.google.protobuf'
android {
compileSdkVersion 28
buildToolsVersion "29.0.0"
defaultConfig {
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main {
proto {
srcDir 'src/main'
}
java {
srcDir 'src/main'
}
}
}
}
protobuf {
protoc { artifact = 'com.google.protobuf:protoc:3.7.1' }
plugins {
javalite { artifact = "com.google.protobuf:protoc-gen-javalite:3.0.0" }
grpc {
artifact = 'io.grpc:protoc-gen-grpc-java:1.20.0' // CURRENT_GRPC_VERSION
}
}
generateProtoTasks {
all().each { task ->
task.plugins {
javalite {}
grpc { // Options added to --grpc_out
option 'lite'
}
}
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.google.android.material:material:1.0.0'
// You need to build grpc-java to obtain these libraries below.
implementation 'io.grpc:grpc-okhttp:1.20.0'
implementation 'io.grpc:grpc-protobuf-lite:1.22.1'
implementation 'io.grpc:grpc-stub:1.20.0'
implementation 'javax.annotation:javax.annotation-api:1.3.2'
implementation 'com.google.protobuf:protobuf-java:3.7.1'
}
given error is:
Duplicate class com.google.protobuf.AbstractMessageLite found in modules protobuf-java-3.7.1.jar (com.google.protobuf:protobuf-java:3.7.1) and protobuf-lite-3.0.1.jar (com.google.protobuf:protobuf-lite:3.0.1)
Duplicate class com.google.protobuf.AbstractMessageLite$Builder found in modules protobuf-java-3.7.1.jar (com.google.protobuf:protobuf-java:3.7.1) and protobuf-lite-3.0.1.jar (com.google.protobuf:protobuf-lite:3.0.1)
Duplicate class com.google.protobuf.AbstractMessageLite$Builder$LimitedInputStream found in modules protobuf-java-3.7.1.jar (com.google.protobuf:protobuf-java:3.7.1) and protobuf-lite-3.0.1.jar (com.google.protobuf:protobuf-lite:3.0.1)
Duplicate class com.google.protobuf.AbstractParser found in modules protobuf-java-3.7.1.jar (com.google.protobuf:protobuf-java:3.7.1) and protobuf-lite-3.0.1.jar (com.google.protobuf:protobuf-lite:3.0.1)
Duplicate class com.google.protobuf.AbstractProtobufList found in modules protobuf-java-3.7.1.jar (com.google.protobuf:protobuf-java:3.7.1) and protobuf-lite-3.0.1.jar (com.google.protobuf:protobuf-lite:3.0.1)
Duplicate class com.google.protobuf.BooleanArrayList found in modules protobuf-java-3.7.1.jar (com.google.protobuf:protobuf-java:3.7.1) and protobuf-lite-3.0.1.jar (com.google.protobuf:protobuf-lite:3.0.1)
Duplicate class com.google.protobuf.ByteBufferWriter found in modules protobuf-java-3.7.1.jar (com.google.protobuf:protobuf-java:3.7.1) and protobuf-lite-3.0.1.jar (com.google.protobuf:protobuf-lite:3.0.1)
Duplicate class com.google.protobuf.ByteOutput found in modules protobuf-java-3.7.1.jar (com.google.protobuf:protobuf-java:3.7.1) and protobuf-lite-3.0.1.jar (com.google.protobuf:protobuf-lite:3.0.1)
Duplicate class com.google.protobuf.ByteString found in modules protobuf-java-3.7.1.jar (com.google.protobuf:protobuf-java:3.7.1) and protobuf-lite-3.0.1.jar (com.google.protobuf:protobuf-lite:3.0.1)
Duplicate class com.google.protobuf.ByteString$1 found in modules protobuf-java-3.7.1.jar (com.google.protobuf:protobuf-java:3.7.1) and protobuf-lite-3.0.1.jar (com.google.protobuf:protobuf-lite:3.0.1)
The missing classes is a known issue. Full proto and lite proto can't be mixed; they use different generated code. Do not depend on protobuf-java as an implementation dependency, but as a protobuf dependency which will cause gradle-protobuf-plugin to generate code for the .protos.
dependencies {
...
protobuf 'com.google.protobuf:protobuf-java:3.7.1'
}
Note that this solution only really works for an application. If you are a library, it is dangerous because users of your library may then see multiple copied of the generated code for the well-known protos.
It happened to me because I added this dependency:
implementation 'com.google.firebase:firebase-firestore-ktx:21.5.0'
There was a problem with the latest version of firestore. Use version 21.4.2 instead of 21.5.0 as of August 2020.
In my case this happened because of mixed package dependencies specifically barcode_scan
This error means that you are importing two packages that use Protobuf for your project, one of them has a distribution that's conflicting with the other.
If you encountered this problem on Flutter, you can reconsider the version number of your dependencies in pubspec.yaml, and replace "any" by an exact version number.
For example, under "dependencies:" change:
barcode_scan: any
To:
barcode_scan: ^2.0.0
I hope I helped.
I'm currently working on an ionic4 application, but recently it stopped working while building the application on an android reall device after adding https://ionicframework.com/docs/native/fcm plugin to the application.
At first it was complaining about fabric key, however I never aimed to use fabric crashlytic on my app.
The error logs:
* What went wrong:
Execution failed for task ':app:checkDebugDuplicateClasses'.
> 1 exception was raised by workers:
java.lang.RuntimeException: Duplicate class android.support.v4.app.INotificationSideChannel found in modules classes.jar (androidx.core:core:1.0.0) and classes.jar (com.android.support:support-compat:27.1.1)
Duplicate class android.support.v4.app.INotificationSideChannel$Stub found in modules classes.jar (androidx.core:core:1.0.0) and classes.jar (com.android.support:support-compat:27.1.1)
Duplicate class android.support.v4.app.INotificationSideChannel$Stub$Proxy found in modules classes.jar (androidx.core:core:1.0.0) and classes.jar (com.android.support:support-compat:27.1.1)
Duplicate class android.support.v4.os.IResultReceiver found in modules classes.jar (androidx.core:core:1.0.0) and classes.jar (com.android.support:support-compat:27.1.1)
Duplicate class android.support.v4.os.IResultReceiver$Stub found in modules classes.jar (androidx.core:core:1.0.0) and classes.jar (com.android.support:support-compat:27.1.1)
Duplicate class android.support.v4.os.IResultReceiver$Stub$Proxy found in modules classes.jar (androidx.core:core:1.0.0) and classes.jar (com.android.support:support-compat:27.1.1)
Duplicate class android.support.v4.os.ResultReceiver found in modules classes.jar (androidx.core:core:1.0.0) and classes.jar (com.android.support:support-compat:27.1.1)
Duplicate class android.support.v4.os.ResultReceiver$1 found in modules classes.jar (androidx.core:core:1.0.0) and classes.jar (com.android.support:support-compat:27.1.1)
Duplicate class android.support.v4.os.ResultReceiver$MyResultReceiver found in modules classes.jar (androidx.core:core:1.0.0) and classes.jar (com.android.support:support-compat:27.1.1)
Duplicate class android.support.v4.os.ResultReceiver$MyRunnable found in modules classes.jar (androidx.core:core:1.0.0) and classes.jar (com.android.support:support-compat:27.1.1)
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 21s
Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.4.1/userguide/command_line_interface.html#sec:command_line_warnings
35 actionable tasks: 5 executed, 30 up-to-date
cmd: Command failed with exit code 1 Error output:
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 android.support.v4.app.INotificationSideChannel found in modules classes.jar (androidx.core:core:1.0.0) and classes.jar (com.android.support:support-compat:27.1.1)
Duplicate class android.support.v4.app.INotificationSideChannel$Stub found in modules classes.jar (androidx.core:core:1.0.0) and classes.jar (com.android.support:support-compat:27.1.1)
Duplicate class android.support.v4.app.INotificationSideChannel$Stub$Proxy found in modules classes.jar (androidx.core:core:1.0.0) and classes.jar (com.android.support:support-compat:27.1.1)
Duplicate class android.support.v4.os.IResultReceiver found in modules classes.jar (androidx.core:core:1.0.0) and classes.jar (com.android.support:support-compat:27.1.1)
Duplicate class android.support.v4.os.IResultReceiver$Stub found in modules classes.jar (androidx.core:core:1.0.0) and classes.jar (com.android.support:support-compat:27.1.1)
Duplicate class android.support.v4.os.IResultReceiver$Stub$Proxy found in modules classes.jar (androidx.core:core:1.0.0) and classes.jar (com.android.support:support-compat:27.1.1)
Duplicate class android.support.v4.os.ResultReceiver found in modules classes.jar (androidx.core:core:1.0.0) and classes.jar (com.android.support:support-compat:27.1.1)
Duplicate class android.support.v4.os.ResultReceiver$1 found in modules classes.jar (androidx.core:core:1.0.0) and classes.jar (com.android.support:support-compat:27.1.1)
Duplicate class android.support.v4.os.ResultReceiver$MyResultReceiver found in modules classes.jar (androidx.core:core:1.0.0) and classes.jar (com.android.support:support-compat:27.1.1)
Duplicate class android.support.v4.os.ResultReceiver$MyRunnable found in modules classes.jar (androidx.core:core:1.0.0) and classes.jar (com.android.support:support-compat:27.1.1)
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 21s
[ERROR] An error occurred while running subprocess cordova.
cordova run android exited with exit code 1.
Re-running this command with the --verbose flag may provide more information.
android/app/build.gradle
buildscript {
repositories {
google()
jcenter()
maven { url 'https://maven.fabric.io/public' } // Fabrics Maven repository from cordova-plugin-firebase
}
dependencies {
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.android.tools.build:gradle:3.4.0+'
classpath 'com.google.gms:google-services:4.2.0' // google-services dependency from cordova-plugin-firebase
classpath 'io.fabric.tools:gradle:1.+' // fabric dependency from cordova-plugin-firebase
}
}
allprojects {
repositories {
jcenter()
google() // Google's Maven repository from cordova-plugin-firebase
}
//This replaces project.properties w.r.t. build settings
project.ext {
defaultBuildToolsVersion="28" //String
defaultMinSdkVersion=19 //Integer - Minimum requirement is Android 4.4
defaultTargetSdkVersion=28 //Integer - We ALWAYS target the latest by default
defaultCompileSdkVersion=28 //Integer - We ALWAYS compile with the latest by default
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
cordova-plugin-firebase/raihan-build.gradle
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.0+'
classpath 'com.google.gms:google-services:4.2.0'
}
}
dependencies {
compile 'me.leolin:ShortcutBadger:1.1.4#aar'
compile 'com.google.firebase:firebase-auth:+'
compile('com.crashlytics.sdk.android:crashlytics:2.9.1#aar') {
transitive = true
}
}
cdvPluginPostBuildExtras.add({
// apply plugin: 'com.google.gms.google-services'
apply plugin: 'io.fabric'
})
cordova-plugin-fcm-with-dependecy-updated/raihan-FCMPlugin.gradle
buildscript {
repositories {
google()
jcenter()
mavenLocal()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.0+'
classpath 'com.google.gms:google-services:4.2.0'
}
}
repositories {
google()
jcenter()
}
dependencies {
compile 'com.google.firebase:firebase-core:16.0.8'
}
// apply plugin: 'com.google.gms.google-services'
// class must be used instead of id(string) to be able to apply plugin from non-root gradle file
// apply plugin: com.google.gms.googleservices.GoogleServicesPlugin
android/project.properties
target=android-27
android.library.reference.1=CordovaLib
android.library.reference.2=app
cordova.gradle.include.1=cordova-android-support-gradle-release/raihan-cordova-android-support-gradle-release.gradle
cordova.system.library.1=com.squareup.okhttp3:okhttp-urlconnection:3.10.0
cordova.system.library.2=com.android.support:support-v4:24.1.1+
cordova.system.library.3=com.soundcloud.android:android-crop:1.0.0#aar
cordova.system.library.4=com.google.firebase:firebase-core:16.0.8
cordova.system.library.4=com.google.firebase:firebase-iid:17.1.1
cordova.system.library.5=com.google.firebase:firebase-messaging:17.5.0
cordova.gradle.include.2=cordova-plugin-fcm-with-dependecy-updated/raihan-FCMPlugin.gradle
cordova.gradle.include.3=cordova-support-google-services/raihan-build.gradle
cordova.system.library.6=com.google.firebase:firebase-auth:16.2.0
cordova.system.library.6=com.google.firebase:firebase-perf:16.2.4
cordova.system.library.7=com.android.support:support-annotations:27.+
cordova.system.library.8=com.android.support:appcompat-v7:23+
cordova.system.library.8=com.google.firebase:firebase-iid:17.1.1
cordova.system.library.8=com.google.android.gms:play-services-tagmanager:16.0.8
cordova.system.library.8=com.google.firebase:firebase-config:16.4.0
cordova.gradle.include.4=cordova-plugin-telerik-imagepicker/raihan-ignorelinterrors.gradle
cordova.gradle.include.5=cordova-plugin-telerik-imagepicker/raihan-androidtarget.gradle
cordova.gradle.include.6=cordova-android-support-gradle-release/raihan-cordova-android-support-gradle-release.gradle
cordova.gradle.include.7=cordova-plugin-firebase/raihan-build.gradle
I have provided the above files, let me know if I need to upload anything else.
Go to gradle.properties(project properties)
Add
android.enableJetifier=true
And also most of time android.useAndroidX=true is present.Check your gradle.properties(Project Properties) and if it does not exist then add
android.useAndroidX=true -> Look Likes This Image
Your project (or one of its sub-projects) is referring to a dependency using a + (plus-sign) at its end, like com.google.firebase:firebase-auth:+, which means, use any higher version when possible, and that newer version is no longer using android.support libraries and instead is using androidx; to fix this issue, either follow the below steps, or, update to androidx by following the other answer.
Steps:
Ensure the ANDROID_HOME environment-variable is set, and then, open a console window (like git-bash, because it keeps the whole command output), and cd into your android directory (for Ionic projects it should be platforms/android).
First, List all dependencies by running below (in git-bash):
./gradlew :app:dependencies
Copy the result into your preferred text-editor, and search for androidx.
If you found something follow below steps, else you are done! (and you do not need to repeat these steps).
Scroll up until you see -> at the end of any line, like for example 16.0.8 -> 19.0.0 or + -> 19.0.0, which both mean that the version was auto-resolved (to something higher than specified by you because of +).
So, set the version down manually:
When possible, in your project find and replace the + sign with a specific version.
Or, force a specific version of the dependencies like mentioned below.
At last, repeat above steps (but instead of step one just clear the console).
To Force specific version of the dependencies add to your root build.gradle something like below (which is what worked for me) but edit and add your own rules (if these do not work for you):
allprojects {
// ...
configurations.all {
resolutionStrategy {
force 'com.google.firebase:firebase-common:17.0.0'
force 'com.google.android.gms:play-services-basement:16.2.0'
force 'com.google.firebase:firebase-iid:16.0.0'
force 'com.google.firebase:firebase-auth:17.0.0'
}
}
}
Simply add below lines into your gradle.properties file:
android.useAndroidX=true
android.enableJetifier=true
Note to check, to not repeat any line that already exists (and ensure existing are true).
Finally, just rebuild your project.
But sometimes you may need to manually delete the build folder.
Details
If you want to use androidx-namespaced libraries in a new project, you need to set the compile SDK to Android 9.0 (API level 28) or higher but below "API level 31", and set both of the mentioned Android Gradle plugin flags to true.
android.useAndroidX: When this flag is set to true, the Android plugin uses the appropriate AndroidX library instead of a Support Library. The flag is false by default if it is not specified.
android.enableJetifier: When this flag is set to true, the Android plugin automatically migrates existing third-party libraries to use AndroidX dependencies by rewriting their binaries. The flag is false by default if it is not specified.
I came across the same problem and My solution is as follows :
Go to gradle.properties files
Add these two lines :
android.useAndroidX=true
android.enableJetifier=true
Rebuild your project.
that's it.
Note: If your project already shows this android.useAndroidX=true then Just add android.enableJetifier=true and rebuild your project.
For me, just installing the plugins "cordova-plugin-androidx" and "cordova-plugin-androidx-adapter" solved this problem:
$ ionic cordova plugin add cordova-plugin-androidx
$ ionic cordova plugin add cordova-plugin-androidx-adapter
I had this issue when I migrated to Androidx using the Android Studio feature but at the first time the migration was not successful so each time I tried to compile I ran into this issue.
To resolve this issue, I did the following:
[1] Comment all androidx dependencies in the app bundle.gradle file
[2] Try the Migrate to Androidx. You can see this link in Refactor -> Migrate to Androidx. If the migration was successful, then
[3] Uncomment all androidx dependencies in the app bundle.gradle file
You may clean and build your project again, hopefully this error should disappear.
In my case, I removed this implementation under dependencies section in app level build.gradle file -
implementation 'com.google.android.gms:play-services-ads:19.2.0'
Remove or comment it out!!
I think you kept same tag multiple time in gradle.properties like following
org.gradle.jvmargs=-Xmx4g -XX:MaxPermSize=2048m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
org.gradle.jvmargs=-Xmx4608m
In my Ionic project I needed to remove the line
cordova.system.library.19=com.google.android.gms:play-services-analytics:11.0.1
from my /platforms/android/project.properties to get a build
Experienced the same problem.
add this dependency to your gradle
implementation 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava'
In my case, i was creating a separate module and importing firebaseAnalytics into that module but it turns out that adding dependency on main module from IDE help caused the issue of duplicate class found.
i removed the dependency and injected it directly, that solved the problem.
hope that helps.
I had the same problem but I solved it as below.
implemetation code in build.gradle
def lifecycle_version = "2.4.0"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
Confirmed in this article
The issue I was facing was in the react-native something similar to
Execution failed for task ':app:checkDebugDuplicateClasses'.
1 exception was raised by workers:
java.lang.RuntimeException: java.lang.RuntimeException: Duplicate class kotlin.collections.jdk8.CollectionsJDK8Kt found in modules jetified-kotlin-stdlib-1.8.0.jar (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk8-1.6.21.jar (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21)
Duplicate class kotlin.internal.jdk7.JDK7PlatformImplementations found in modules jetified-kotlin-stdlib-1.8.0.jar (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk7-1.6.21.jar (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.21)
It means that there is a conflict between two different versions of the Kotlin standard library, specifically the "jetified-kotlin-stdlib-1.8.0.jar" and "jetified-kotlin-stdlib-jdk8-1.6.21.jar" versions. The error message specifically states that there is a duplicate class "kotlin.collections.jdk8.CollectionsJDK8Kt" found in both versions.
and the solution was here
there were two approaches but i found this one easier go to android/app/build.gradle and update the dependencies
dependencies {
constraints {
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.8.0") {
because("kotlin-stdlib-jdk7 is now a part of kotlin-stdlib")
}
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.0") {
because("kotlin-stdlib-jdk8 is now a part of kotlin-stdlib")
}
}
I had the same problem but i solved it as below.
Open Android studio>
File > Invalidate Caches/Restart…
I'm in the process of adding a navigation drawer to my app. and I'm getting errors. The app gradle synchs just fine. but when I run the app I get a bunch of duplicate class error. I think it might be because I have conflicting dependencies added and that I'm using v7 28.0.0 and some of the errors mention app: v4. all the examples I've seen online use v7 28.0.0 eventhough I have this in main_activity.xml which uses v4. don't know if it's got something to do with the error. android.support.v4.widget.DrawerLayout
Caused by: com.android.ide.common.workers.WorkerExecutorException: 1 exception was raised by workers:
java.lang.RuntimeException: java.lang.RuntimeException: Duplicate class android.support.v4.accessibilityservice.AccessibilityServiceInfoCompat found in modules classes.jar (com.android.support:support-compat:28.0.0) and classes.jar (com.android.support:support-v4:24.0.0)
Duplicate class android.support.v4.app.ActionBarDrawerToggle found in modules classes.jar (com.android.support:support-core-ui:28.0.0) and classes.jar (com.android.support:support-v4:24.0.0)
Duplicate class android.support.v4.app.ActionBarDrawerToggle$Delegate found in modules classes.jar (com.android.support:support-core-ui:28.0.0) and classes.jar (com.android.support:support-v4:24.0.0)
Duplicate class android.support.v4.app.ActionBarDrawerToggle$DelegateProvider found in modules classes.jar (com.android.support:support-core-ui:28.0.0) and classes.jar (com.android.support:support-v4:24.0.0)
Duplicate class android.support.v4.app.ActionBarDrawerToggle$SlideDrawable found in modules classes.jar (com.android.support:support-core-ui:28.0.0) and classes.jar (com.android.support:support-v4:24.0.0)
Duplicate class android.support.v4.app.ActivityCompat found in modules classes.jar (com.android.support:support-compat:28.0.0) and classes.jar (com.android.support:support-v4:24.0.0)
Duplicate class android.support.v4.app.ActivityCompat$1 found in modules classes.jar (com.android.support:support-compat:28.0.0) and classes.jar (com.android.support:support-v4:24.0.0)
Duplicate class android.support.v4.app.ActivityCompat$OnRequestPermissionsResultCallback found in modules classes.jar (com.android.support:support-compat:28.0.0) and classes.jar (com.android.support:support-v4:24.0.0)
gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "org.pctechtips.netdroid"
minSdkVersion 21
targetSdkVersion 28
versionCode 8
versionName "1.7"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled = false
signingConfig signingConfigs.config
}
buildTypes {
release {
shrinkResources false
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
debuggable false
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
/*androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
firebase
implementation 'com.google.firebase:firebase-core:10.2.1'
})*/
// compile 'com.android.support:appcompat-v7:25.3.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
/*google play plugin for adMob*/
implementation 'com.google.android.gms:play-services:10.2.1'
implementation 'commons-net:commons-net:3.6'
implementation 'org.samba.jcifs:jcifs:1.3.3'
}
The exception means, There were duplicated classes in 2 or more different dependencies and the compiler wouldn't be able to distinguish which of them should be used at run-time and the exception was thrown.
Most often, Duplicity happens when you are trying to import modules that carrying their required libraries. (transitive dependencies)
You have to exclude duplicated classes from libraries in the build.gradle.
As Log shows, support-core-ui and support-compat modules have duplicated classes.
apply plugin: 'com.android.application'
android {
...
defaultConfig {
...
}
buildTypes {
...
}
configurations {
all { // You should exclude one of them not both of them
exclude group: "com.android.support", module: "support-core-ui"
exclude group: "com.android.support", module: "support-compat"
}
}
}
Sometimes you don't need to exclude anything and you only need to change the imported module to that one that does not bring its dependencies.
Other situation that causes duplicated classes is when you have added *.jar to the project libs directory. Therefore, You need to delete them if they are not begin used in the project.
project->app->libs->*.jar
I see there are some solutions mentioned using these 2 lines will resolve the problem But if you've migrated to Androidx it would be enabled by default.
android.useAndroidX=true
android.enableJetifier=true
Jetifier is
Jetifier tool migrates support-library-dependent libraries to rely on
the equivalent AndroidX packages instead. The tool lets you migrate an
individual library directly, instead of using the Android gradle
plugin bundled with Android Studio.
And for more information take a look at Exclude transitive dependencies
As an app grows in scope, it can contain a number of dependencies
including direct dependencies and transitive dependencies (libraries
which your app's imported libraries depend on). To exclude transitive
dependencies that you no longer need, you can use the exclude
keyword
If you have problems excluding classes, check this thread: How do I exclude...
See if adding this dependency works:
implementation 'com.android.support:support-v4:28.0.0'
Go to gradle.properties and write these two lines of code:
android.useAndroidX=true
android.enableJetifier=true
Please update com.google.android.gms:play-services to latest version. it wil work.
I tried all above solution, but nothing worked in my case. What worked for me is.
I got this problem resolved by creating a new project with the same project and package name and then copying files from the previous project to new one.