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

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"
}

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'
}
`

Gradle duplicated class

In my Android app, I added a new dependency in the Gradle file. It turned out that this dependency is conflicting with one of the other dependencies in the project. When I'm trying to build the app I get the following error:
Duplicate class android.content.pm.IPackageStatsObserver found in modules jetified-androidcommon-debug-1.2.2-runtime (com.myapp.androidcommon:androidcommon-debug:1.2.2) and jetified-framework-1.12.0-runtime (com.dependency:framework:1.12.0)
Duplicate class android.content.pm.IPackageStatsObserver$Stub found in modules jetified-androidcommon-debug-1.2.2-runtime (com.myapp.androidcommon:androidcommon-debug:1.2.2) and jetified-framework-1.12.0-runtime (com.dependency:framework:1.12.0)
Duplicate class android.content.pm.IPackageStatsObserver$Stub$Proxy found in modules jetified-androidcommon-debug-1.2.2-runtime (com.myapp.androidcommon:androidcommon-debug:1.2.2) and jetified-framework-1.12.0-runtime (com.dependency:framework:1.12.0)
As the log shows the problem is 3 duplicated classes that are present in both dependencies. To solve this I tried to exclude the android.content.pm package from one or the other dependency like that:
implementation ('com.dependency:framework:1.12.0') {
exclude group: 'android.content.pm'
}
or like that:
implementation('com.myapp.androidcommon:androidcommon-debug:1.2.2') {
exclude group: 'android.content.pm'
}
but I keep getting the same error. Any idea how to solve this issue?

Duplicate classes found in Gradle when trying to use Paging Library 3

I am trying to implement paging using Paging Library 3. However, I cannot run my project after doing all the necessary steps (paging source, flow, and etc). This is the list of my dependencies:
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)
Duplicate class kotlinx.coroutines.AwaitAll$DisposeHandlersOnCancel 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)
It's not the full stack trace. Some of my dependencies:
// Coroutines
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.1'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.1'
// Paging
implementation 'androidx.paging:paging-runtime-ktx:3.0.0-alpha12'
// Image Compressor
implementation 'id.zelory:compressor:3.0.0' // this lib also uses coroutines
Also, I've tried excluding some dependencies this way:
implementation 'androidx.paging:paging-runtime-ktx:3.0.0-alpha12' {
exclude group: 'org.jetbrains.kotlinx', module: 'kotlinx-coroutines-core-jvm'
But it produces the following error:
A problem occurred evaluating project ':app'.
> Could not find method androidx.paging:paging-runtime-ktx:3.0.0-alpha12() for arguments [build_cmaofa0fil3wjmmcunq4oc9m5$_run_closure2$_closure8#2e68c056] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
I tried running an example project downloaded from a raywenderlich tutorial and it runs fine with the same dependencies. Migrating to Paging v2 resolves the issue but I would like to use the new functionality in the updated version.
You should write the dependency like this to avoid using from the below-stated module and group. You can also check for the module and/or package with the duplicate classes by checking the error message and pasting it here.
implementation ('androidx.paging:paging-runtime:3.0.0-alpha12') {
exclude group: 'org.jetbrains.kotlinx', module: 'kotlinx-coroutines-core-jvm'
}
it looks like you are using wrong dependency. change to below line :
implementation "androidx.paging:paging-runtime:3.0.0-alpha12"
BTW, I had to use a stable version of paging.
For me, the below solution worked. I hope this solution also might be helpful in some cases.
implementation ('androidx.paging:paging-runtime-ktx:3.0.0') {
exclude group: 'org.jetbrains.kotlinx'
}

How to exclude Duplicate Class without changing Version

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

Duplicate class com.google.api.client.http.apache.ApacheHttpRequest found in modules

I am trying to migrate to drive v3 api for my android app and I have followed instructions provided inhttps://github.com/gsuitedevs/android-samples/tree/master/drive/deprecation to migrate. I am getting dependency resolution errors.
I have used duplicate classes shown in log in exclude option but it haven't worked
list of my drive api dependencies
implementation 'com.google.android.gms:play-services-ads:17.2.0'
implementation 'com.google.android.gms:play-services-auth:16.0.1'
implementation 'com.google.http-client:google-http-client-gson:1.29.1'
implementation('com.google.api-client:google-api-client-android:1.28.0') {
exclude group: 'org.apache.httpcomponents'
}
implementation('com.google.apis:google-api-services-drive:v3-rev99-1.23.0') {
exclude group: 'org.apache.httpcomponents'
}
Below are the error lines shown
Duplicate class com.google.api.client.http.apache.ApacheHttpRequest found in modules google-http-client-1.29.1.jar (com.google.http-client:google-http-client:1.29.1) and google-http-client-apache-2.0.0.jar (com.google.http-client:google-http-client-apache:2.0.0)
Duplicate class com.google.api.client.http.apache.ApacheHttpResponse found in modules google-http-client-1.29.1.jar (com.google.http-client:google-http-client:1.29.1) and google-http-client-apache-2.0.0.jar (com.google.http-client:google-http-client-apache:2.0.0)
Duplicate class com.google.api.client.http.apache.ApacheHttpTransport found in modules google-http-client-1.29.1.jar (com.google.http-client:google-http-client:1.29.1) and google-http-client-apache-2.0.0.jar (com.google.http-client:google-http-client-apache:2.0.0)
Duplicate class com.google.api.client.http.apache.ContentEntity found in modules google-http-client-1.29.1.jar (com.google.http-client:google-http-client:1.29.1) and google-http-client-apache-2.0.0.jar (com.google.http-client:google-http-client-apache:2.0.0)
Duplicate class com.google.api.client.http.apache.HttpExtensionMethod found in modules google-http-client-1.29.1.jar (com.google.http-client:google-http-client:1.29.1) and google-http-client-apache-2.0.0.jar (com.google.http-client:google-http-client-apache:2.0.0)
Looking at the error message:
found in modules google-http-client-1.29.1.jar
it seems to reference:
implementation 'com.google.http-client:google-http-client-gson:1.29.1'
Based upon the version number. Have you tried to exclude the library from that artefact too?

Categories

Resources