How to exclude Duplicate Class without changing Version - android

I'm using Coroutine and Paging 3 Libary on my project on changing new Version of libary most of the time i will get this Duplicate Class Error , So what is the proper way to get rid of such problems with changing library version...
Duplicate class kotlinx.coroutines.AbstractCoroutine found in modules jetified-kotlinx-
coroutines-core-jvm-1.4.1.jar (org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.4.1) and
jetified-kotlinx-coroutines-core-jvm-1.4.1.jar (org.jetbrains.kotlinx:kotlinx-coroutines-
core:1.4.1)
Duplicate class kotlinx.coroutines.Active found in modules jetified-kotlinx-coroutines-core-
jvm-1.4.1.jar (org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.4.1) and jetified-kotlinx-
coroutines-core-jvm-1.4.1.jar (org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.1)
Duplicate class kotlinx.coroutines.AwaitAll found in modules jetified-kotlinx-coroutines-core-
jvm-1.4.1.jar (org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.4.1) and jetified-kotlinx-
coroutines-core-jvm-1.4.1.jar (org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.1)
Duplicate class kotlinx.coroutines.AwaitAll$AwaitAllNode found in modules jetified-kotlinx-
coroutines-core-jvm-1.4.1.jar (org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.4.1) and
jetified-kotlinx-coroutines-core-jvm-1.4.1.jar (org.jetbrains.kotlinx:kotlinx-coroutines-
core:1.4.1)

I resolved it.
def paging_version_3 = "3.0.0-alpha12"
implementation ("androidx.paging:paging-runtime-ktx:$paging_version_3")
{
exclude group: 'org.jetbrains.kotlinx', module: 'kotlinx-coroutines-core-jvm'
}
// optional - RxJava3 support
implementation ("androidx.paging:paging-rxjava3:$paging_version_3")
{
exclude group: 'org.jetbrains.kotlinx', module: 'kotlinx-coroutines-core-jvm'
}
// leanback paging library
implementation ("androidx.leanback:leanback-paging:1.1.0-alpha07")
{
exclude group: 'org.jetbrains.kotlinx', module: 'kotlinx-coroutines-core-jvm'
}

exclude group: 'org.jetbrains.kotlinx', module: 'kotlinx-coroutines-core-jvm'
You can remove and clear the cache and recompile it , under the Gradle Plugin module,find the Dependencies under Help

Related

Duplicate class com.google.firebase.iid.FirebaseInstanceIdReceiver found in modules

Duplicate class com.google.firebase.iid.FirebaseInstanceIdReceiver found in modules jetified-firebase-iid-20.1.5-runtime (com.google.firebase:firebase-iid:20.1.5) and jetified-firebase-messaging-23.1.1-runtime (com.google.firebase:firebase-messaging:23.1.1)
I'm trying to integrate the Carrot Quest library and I'm facing a dependency conflict problem.
I tried to do exclude group, but without success
`
implementation ('io.carrotquest:android-sdk:1.0.60-commonRelease') {
exclude group: 'com.google.firebase'
}
`

Duplicate class androidx.lifecycle.ViewModelLazy found in modules jetified-lifecycle-viewmodel-ktx-2.3.1-runtime and lifecycle-viewmodel-2.5.1-runtime

getting build error
I had also tried with adding
android.enableJetifier=true
but, still getting error
Run gradle dependencies
Find jetified-lifecycle-viewmodel-ktx-2.3.1-runtime is which libraries dependencies
Exclude it like:
.
implementation('...yourlibray...') {
exclude group: 'androidx.lifecycle', module: 'lifecycle-viewmodel'
}

Duplicate class com.google.android.flexbox - Android Admob

I am using admob and facebook for ads in my app and its done but I want to check it so i have added Mediation Test Suite depnedancy
implementation 'com.google.android.ads:mediation-test-suite:2.0.0'
And the app could not build it shows
Duplicate class com.google.android.flexbox.AlignContent found in modules jetified-flexbox-1.1.1-runtime (com.google.android:flexbox:1.1.1) and jetified-flexbox-3.0.0-runtime (com.google.android.flexbox:flexbox:3.0.0)
Duplicate class com.google.android.flexbox.AlignItems found in modules jetified-flexbox-1.1.1-runtime (com.google.android:flexbox:1.1.1) and jetified-flexbox-3.0.0-runtime (com.google.android.flexbox:flexbox:3.0.0)
And many more Duplicate Class of Flexbox
my admob version
implementation 'com.google.android.gms:play-services-ads:20.4.0'
The package name is wrong.
com.google.android:flexbox:1.1.1
Here is the correct one. ↓
implementation ('com.google.android.ads:mediation-test-suite:2.0.0') {
exclude group: "com.google.android", module: "flexbox"
}
It worked for me.
Exclude the flexbox module which is causing the conflict like this...
implementation ('com.google.android.ads:mediation-test-suite:2.0.0') {
exclude group: "com.google.android.flexbox", module: "flexbox"
}

Duplicate class using product flavours

My android gradle build has many flavours.
One of then has an aar file that contains a duplicate dependency (com.google.zxing).
build.gradle:
...
dependencies {
implementation 'com.google.zxing:core:3.3.3'
implementation 'me.dm7.barcodescanner:zxing:1.9.8'
// Standard flavour
standardImplementation(name: 'libgedi-0.190121.gpos800', ext: 'aar') {
exclude group: 'com.google.zxing', module: 'android-core'
transitive = false
}
...
}
This configuration produces the following for "standard" build (works for another flavours):
Duplicate class com.google.zxing.BarcodeFormat found in modules core-3.3.3.jar (com.google.zxing:core:3.3.3) and zxing-2.1.jar (:libgedi-0.190121.gpos800:)
Duplicate class com.google.zxing.Binarizer found in modules core-3.3.3.jar (com.google.zxing:core:3.3.3) and zxing-2.1.jar (:libgedi-0.190121.gpos800:)
Duplicate class com.google.zxing.BinaryBitmap found in modules core-3.3.3.jar (com.google.zxing:core:3.3.3) and zxing-2.1.jar (:libgedi-0.190121.gpos800:)
Duplicate class com.google.zxing.ChecksumException found in modules core-3.3.3.jar (com.google.zxing:core:3.3.3) and zxing-2.1.jar (:libgedi-0.190121.gpos8
...
I tried to change the config to:
standardImplementation(name: 'libgedi-0.190121.gpos800', ext: 'aar') {
configurations {
all*.exclude group: 'com.google.zxing'
}
}
The config above works only when i'm build the "standard" flavour. To another flavors, this error occurs:
error: package com.google.zxing.qrcode.decoder does not exist
What i'm doing wrong?
Solution:
{
configurations {
exclude group: 'com.google.zxing'
}
}
use exclude instead all*exclude

How to exclude certain part of a gradle dependecy?

Multiple dependencies has similar named class and I'm getting duplicate class errors. To solve I think excluding those parts may help. How to exclude these parts?
Errors +lots of similar lines:
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)
Dependencies:
// gRPC
implementation "io.grpc:grpc-okhttp:$grpcVersion"
implementation "io.grpc:grpc-protobuf-lite:$grpcVersion"
implementation "io.grpc:grpc-stub:$grpcVersion"
implementation 'javax.annotation:javax.annotation-api:1.3.2'
//protobuf 'com.google.protobuf:protobuf-java:3.8.0'//error persist with this and without this
// OAuth2 for Google API
implementation('com.google.auth:google-auth-library-oauth2-http:0.7.0') {
exclude module: 'httpclient'
}
//Translation
implementation "com.google.cloud:google-cloud-translate:$grpcVersion"
implementation('com.google.cloud:google-cloud-translate:1.79.0') {
exclude group: 'org.apache.httpcomponents'
exclude group: 'org.json', module: 'json'
//I want to exclude error classes here...HOW?...
//exclude group: 'com.google.protobuf', module: 'protobuf-java-3.7.1'
}
annotationProcessor "com.google.cloud:google-cloud-translate:$grpcVersion"
grpc version on ext:
grpcVersion = '1.4.0'
these are not related to support library versions as these are because of translation and protobuf-lite libraries. these are using different versions of those class and I dont know if excluding of them will work or not.
Is it possible to extract those libraries and change those class names?
I want to see if excluding those classes can solve it. How to exclude?

Categories

Resources