I am getting the following error when Gradle is set 7.2.2.
Duplicate class androidx.lifecycle.ViewModelLazy found in modules jetified-lifecycle-viewmodel-ktx-2.3.1-runtime (androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1) and lifecycle-viewmodel-2.5.1-runtime (androidx.lifecycle:lifecycle-viewmodel:2.5.1)
Duplicate class androidx.lifecycle.ViewTreeViewModelKt found in modules jetified-lifecycle-viewmodel-ktx-2.3.1-runtime (androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1) and lifecycle-viewmodel-2.5.1-runtime (androidx.lifecycle:lifecycle-viewmodel:2.5.1)
This is not in my program but in Android Studio.
How do I correct the problem?
Thanks,
Bill
In your build.gradle try adding this:
implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.5.1"
This worked for me.
I added it but no change.
Duplicate class androidx.lifecycle.ViewModelLazy found in modules jetified-lifecycle-viewmodel-ktx-2.3.1-runtime (androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1) and lifecycle-viewmodel-2.5.1-runtime (androidx.lifecycle:lifecycle-viewmodel:2.5.1)
Duplicate class androidx.lifecycle.ViewTreeViewModelKt found in modules jetified-lifecycle-viewmodel-ktx-2.3.1-runtime (androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1) and lifecycle-viewmodel-2.5.1-runtime (androidx.lifecycle:lifecycle-viewmodel:2.5.1)
This error is caused by duplication of dependencies
To solve the same:
You must open Gradle Scripts-->build.gradle(Module: YourApp)
Or
You can just choose to search the builder:app file in Navigate--> Search Everywhere, type "build.gradle " and choose the option that appears build.gradle (: app)
Inside your build.gradle file it checks which of the implementations made in the dependencies tag was duplicated and deletes one of them.
Now
rebuild your app and good work!
Related
I am getting this build error while I am trying to run my application from Android Studio.
Execution failed for task ':app:checkDebugDuplicateClasses'.
> 1 exception was raised by workers:
java.lang.RuntimeException: java.lang.RuntimeException: Duplicate class com.google.android.gms.internal.measurement.zzbs found in modules jetified-play-services-measurement-18.0.1-runtime.jar (com.google.android.gms:play-services-measurement:18.0.1) and jetified-play-services-measurement-sdk-api-18.0.3-runtime.jar (com.google.android.gms:play-services-measurement-sdk-api:18.0.3)
Duplicate class com.google.android.gms.internal.measurement.zzl found in modules jetified-play-services-measurement-impl-18.0.1-runtime.jar (com.google.android.gms:play-services-measurement-impl:18.0.1) and jetified-play-services-measurement-sdk-api-18.0.3-runtime.jar (com.google.android.gms:play-services-measurement-sdk-api:18.0.3)
Duplicate class com.google.android.gms.measurement.internal.zzfh found in modules jetified-play-services-measurement-base-18.0.3-runtime.jar (com.google.android.gms:play-services-measurement-base:18.0.3) and jetified-play-services-measurement-impl-18.0.1-runtime.jar (com.google.android.gms:play-services-measurement-impl:18.0.1)
Duplicate class com.google.android.gms.measurement.internal.zzgl found in modules jetified-play-services-measurement-18.0.1-runtime.jar (com.google.android.gms:play-services-measurement:18.0.1) and jetified-play-services-measurement-base-18.0.3-runtime.jar (com.google.android.gms:play-services-measurement-base:18.0.3)
Duplicate class com.google.android.gms.measurement.internal.zzgm found in modules jetified-play-services-measurement-18.0.1-runtime.jar (com.google.android.gms:play-services-measurement:18.0.1) and jetified-play-services-measurement-base-18.0.3-runtime.jar (com.google.android.gms:play-services-measurement-base:18.0.3)
Duplicate class com.google.android.gms.measurement.internal.zzgn found in modules jetified-play-services-measurement-18.0.1-runtime.jar (com.google.android.gms:play-services-measurement:18.0.1) and jetified-play-services-measurement-base-18.0.3-runtime.jar (com.google.android.gms:play-services-measurement-base:18.0.3)
Duplicate class com.google.android.gms.measurement.internal.zzgo found in modules jetified-play-services-measurement-18.0.1-runtime.jar (com.google.android.gms:play-services-measurement:18.0.1) and jetified-play-services-measurement-base-18.0.3-runtime.jar (com.google.android.gms:play-services-measurement-base:18.0.3)
Duplicate class com.google.android.gms.measurement.internal.zzgp found in modules jetified-play-services-measurement-base-18.0.3-runtime.jar (com.google.android.gms:play-services-measurement-base:18.0.3) and jetified-play-services-measurement-impl-18.0.1-runtime.jar (com.google.android.gms:play-services-measurement-impl:18.0.1)
Duplicate class com.google.android.gms.measurement.internal.zzgq found in modules jetified-play-services-measurement-base-18.0.3-runtime.jar (com.google.android.gms:play-services-measurement-base:18.0.3) and jetified-play-services-measurement-impl-18.0.1-runtime.jar (com.google.android.gms:play-services-measurement-impl:18.0.1)
Duplicate class com.google.android.gms.measurement.internal.zzhs found in modules jetified-play-services-measurement-base-18.0.3-runtime.jar (com.google.android.gms:play-services-measurement-base:18.0.3) and jetified-play-services-measurement-impl-18.0.1-runtime.jar (com.google.android.gms:play-services-measurement-impl:18.0.1)
Duplicate class com.google.android.gms.measurement.internal.zzhx found in modules jetified-play-services-measurement-base-18.0.3-runtime.jar (com.google.android.gms:play-services-measurement-base:18.0.3) and jetified-play-services-measurement-impl-18.0.1-runtime.jar (com.google.android.gms:play-services-measurement-impl:18.0.1)
This only happens after I update ads dependencies to the latest version.
From :
implementation 'com.google.android.gms:play-services-ads:20.0.0'
To :
implementation 'com.google.android.gms:play-services-ads:20.4.0'
If I change it back to 20.0.0 then it's working fine. I think the problem is with the latest version 20.4.0.
Can anybody help me please? Thanks in advance.
The release notes are not giving a hint.
I ended up using 20.3.0 for now which does not produce this error.
Another Google owned library has a conflicting version of com.google.android.gms:play-services-measurement-base installed. In my case it was Firebase Analytics.
Firebase Analytics
+--- com.google.firebase:firebase-analytics:18.0.0
| +--- com.google.android.gms:play-services-measurement:18.0.0
Play Services Ads
+--- com.google.android.gms:play-services-ads:20.6.0
| +--- com.google.android.gms:play-services-ads-lite:20.6.0
| | +--- com.google.android.gms:play-services-measurement-sdk-api:18.0.3
| | | \--- com.google.android.gms:play-services-measurement-base:18.0.3
After upgrading Firebase Analytics from version 18.0.0 to 20.1.2 it solved the issue.
To determine which library is conflicting in your project, output your dependency tree and find which library also installs com.google.android.gms:play-services-measurement-base. Then upgrade that library to the latest version.
See also
Duplicate class com.google.android.gms.internal.measurement.zzdu found in modules classes.jar com.google.android.gms:play-services-measurement-impl:
com.google.android.gms:play-services-measurement-base is being requested by various other libraries
Fix dependency resolution errors
View module dependencies
So I tried running ionic cordova run android but I get a build failed with an exception.
Duplicate class com.google.zxing.Binarizer found in modules jetified-com.google.zxing.client.android.captureactivity.jar (com.google.zxing.client.android.captureactivity.jar) and jetified-core-3.3.3.jar (com.google.zxing:core:3.3.3)
Duplicate class com.google.zxing.BinaryBitmap found in modules jetified-com.google.zxing.client.android.captureactivity.jar (com.google.zxing.client.android.captureactivity.jar) and jetified-core-3.3.3.jar (com.google.zxing:core:3.3.3)
Duplicate class com.google.zxing.ChecksumException found in modules jetified-com.google.zxing.client.android.captureactivity.jar (com.google.zxing.client.android.captureactivity.jar) and jetified-core-3.3.3.jar (com.google.zxing:core:3.3.3)
Duplicate class com.google.zxing.DecodeHintType found in modules jetified-com.google.zxing.client.android.captureactivity.jar (com.google.zxing.client.android.captureactivity.jar) and jetified-core-3.3.3.jar (com.google.zxing:core:3.3.3)
Duplicate class com.google.zxing.EncodeHintType found in modules jetified-com.google.zxing.client.android.captureactivity.jar (com.google.zxing.client.android.captureactivity.jar) and jetified-core-3.3.3.jar (com.google.zxing:core:3.3.3)
Duplicate class com.google.zxing.FormatException found in modules jetified-com.google.zxing.client.android.captureactivity.jar (com.google.zxing.client.android.captureactivity.jar) and jetified-core-3.3.3.jar (com.google.zxing:core:3.3.3)
Duplicate class com.google.zxing.LuminanceSource found in modules jetified-com.google.zxing.client.android.captureactivity.jar (com.google.zxing.client.android.captureactivity.jar) and jetified-core-3.3.3.jar (com.google.zxing:core:3.3.3)
Duplicate class com.google.zxing.MultiFormatReader found in modules jetified-com.google.zxing.client.android.captureactivity.jar (com.google.zxing.client.android.captureactivity.jar) and jetified-core-3.3.3.jar (com.google.zxing:core:3.3.3)
Duplicate class com.google.zxing.MultiFormatWriter found in modules jetified-com.google.zxing.client.android.captureactivity.jar (com.google.zxing.client.android.captureactivity.jar) and jetified-core-3.3.3.jar (com.google.zxing:core:3.3.3)
Duplicate class com.google.zxing.MultiFormatWriter$1 found in modules jetified-com.google.zxing.client.android.captureactivity.jar (com.google.zxing.client.android.captureactivity.jar) and jetified-core-3.3.3.jar (com.google.zxing:core:3.3.3)
Duplicate class com.google.zxing.NotFoundException found in modules jetified-com.google.zxing.client.android.captureactivity.jar (com.google.zxing.client.android.captureactivity.jar) and jetified-core-3.3.3.jar (com.google.zxing:core:3.3.3)
Duplicate class com.google.zxing.PlanarYUVLuminanceSource found in modules jetified-com.google.zxing.client.android.captureactivity.jar (com.google.zxing.client.android.captureactivity.jar) and jetified-core-3.3.3.jar (com.google.zxing:core:3.3.3)
Duplicate class com.google.zxing.RGBLuminanceSource found in modules jetified-com.google.zxing.client.android.captureactivity.jar (com.google.zxing.client.android.captureactivity.jar) and jetified-core-3.3.3.jar (com.google.zxing:core:3.3.3)
Duplicate class com.google.zxing.Reader found in modules jetified-com.google.zxing.client.android.captureactivity.jar (com.google.zxing.client.android.captureactivity.jar) and jetified-core-3.3.3.jar (com.google.zxing:core:3.3.3)
And the list goes on and finishes with :
Duplicate class com.google.zxing.qrcode.encoder.QRCode found in modules jetified-com.google.zxing.client.android.captureactivity.jar (com.google.zxing.client.android.captureactivity.jar) and jetified-core-3.3.3.jar (com.google.zxing:core:3.3.3)
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
Deprecated Gradle features were used in this build, making it
incompatible with Gradle 7.0. Use '--warning-mode all' to show the
individual deprecation warnings. See
https://docs.gradle.org/6.5/userguide/command_line_interface.html#sec:command_line_warnings
Here is my build.gradle file :
buildscript {
ext.kotlin_version = '1.3.50'
apply from: 'repositories.gradle'
repositories repos
dependencies {
classpath 'com.android.tools.build:gradle:4.0.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
apply from: 'repositories.gradle'
repositories repos
project.ext {
defaultBuildToolsVersion="29.0.2" //String
defaultMinSdkVersion=22 //Integer - Minimum requirement is Android 5.1
defaultTargetSdkVersion=29 //Integer - We ALWAYS target the latest by default
defaultCompileSdkVersion=29 //Integer - We ALWAYS compile with the latest by default
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I Tried :
Adding : configurations {compile.exclude group: 'com.google.zxing'} to build.gradle
removed the android platform from cordova and then adding it.
removed the barcodescanner plugin then adding it.
I have been stuck with this one for almost a week.
The problem was caused because of a conflict between facebook4 plugin and barcodeScanner plugin. Both use a library called ZXing which will cause a conflict.
The easy fix (hard to find) was to remove the facebook plugin and add the same one without the zxing library.
ionic cordova platform rm android
ionic cordova plugin rm cordova-plugin-facebook4 --save --variable APP_ID="ID" --variable APP_NAME="NAME"
ionic cordova plugin add https://github.com/AndreiTelteu/cordova-plugin-facebook4-no-zxing --save --variable APP_ID="ID" --variable APP_NAME="NAME"
ionic cordova platform add android
ionic cordova platform rm android
This fixed my problem. Note that there is nothing to edit in your code.
Check the git repo for more info: https://github.com/AndreiTelteu/cordova-plugin-facebook4-no-zxing
For me, the solution was to remove implementation files('libs/core.jar') from my build.gradle:
dependencies {
..........
implementation files('libs/core.jar') // Remove this line
implementation 'com.facebook.android:facebook-login:latest.release' // Conflicting with libs/core.jar.
..........
}
when i add this : implementation 'com.github.barteksc:android-pdf-viewer:2.8.2' in gradle build
then run this and then showing error that is given below: 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)
Latest versions of android parse SDK (1.24.x) include bolts-tasks instead of referencing it. In an app which also use Facebook SDK this leads to duplicate classes :
java.lang.RuntimeException: Duplicate class bolts.AggregateException found in modules bolts-tasks-1.24.1.jar (com.github.parse-community.Parse-SDK-Android:bolts-tasks:1.24.1) and bolts-tasks-1.4.0.jar (com.parse.bolts:bolts-tasks:1.4.0)
Duplicate class bolts.AndroidExecutors found in modules bolts-tasks-1.24.1.jar (com.github.parse-community.Parse-SDK-Android:bolts-tasks:1.24.1) and bolts-tasks-1.4.0.jar (com.parse.bolts:bolts-tasks:1.4.0)
Duplicate class bolts.AndroidExecutors$1 found in modules bolts-tasks-1.24.1.jar (com.github.parse-community.Parse-SDK-Android:bolts-tasks:1.24.1) and bolts-tasks-1.4.0.jar (com.parse.bolts:bolts-tasks:1.4.0)
Duplicate class bolts.AndroidExecutors$UIThreadExecutor found in modules bolts-tasks-1.24.1.jar (com.github.parse-community.Parse-SDK-Android:bolts-tasks:1.24.1) and bolts-tasks-1.4.0.jar (com.parse.bolts:bolts-tasks:1.4.0)
Duplicate class bolts.BoltsExecutors found in modules bolts-tasks-1.24.1.jar (com.github.parse-community.Parse-SDK-Android:bolts-tasks:1.24.1) and bolts-tasks-1.4.0.jar (com.parse.bolts:bolts-tasks:1.4.0)
Duplicate class bolts.BoltsExecutors$1 found in modules bolts-tasks-1.24.1.jar (com.github.parse-community.Parse-SDK-Android:bolts-tasks:1.24.1) and bolts-tasks-1.4.0.jar (com.parse.bolts:bolts-tasks:1.4.0)
...
Is there a solution ?
try this
implementation ("com.github.parse-community.Parse-SDK-Android:parse:1.24.1"){
exclude module:'bolts-tasks'
}
If it doesn't work then try this
implementation ("com.github.parse-community.Parse-SDK-Android:parse:1.24.1"){
exclude group:'com.github.parse-community' ,module:'bolts-tasks'
}
if you are using com.facebook.fresco:fresco then following solution is working
implementation ('com.facebook.fresco:fresco:2.1.0'){
exclude module:'bolts-tasks'
}
implementation "com.github.parse-community.Parse-SDK-Android:parse:1.24.1"
try this works for me
implementation "com.github.parse-community.Parse-SDK-Android:parse:1.24.1"
implementation ('com.github.parse-community:ParseFacebookUtils-Android:1.14.0'){
exclude module: 'bolts-android'
}
Duplicate class android.support.v4.app.INotificationSideChannel found in modules classes.jar (androidx.core:core:1.1.0) and classes.jar (com.android.support:support-v4:23.4.0)
In your app's build.gradle file, remove references to com.android.support if you are using androidx. Posting your app module's build.gradle file would be helpful if that doesn't work.
Reference:
https://developer.android.com/jetpack/androidx/migrate/artifact-mappings