ChuckerTeam / chucker

🔎 An HTTP inspector for Android & OkHTTP (like Charles but on device)
Apache License 2.0
3.97k stars 351 forks source link

Duplicate class found #748

Closed noureldeen-abouelkassem closed 2 years ago

noureldeen-abouelkassem commented 2 years ago

:writing_hand: Describe the bug

I'm using Chucker in an android library and also in another app that depended on the library. When I add the library as a dependency for the App. I get a conflict issue that tells me that all chucker classes are defined twice.

Duplicate class com.chuckerteam.chucker.api.ChuckerCollector found in modules jetified-library-3.5.2-runtime (com.github.chuckerteam.chucker:library:3.5.2) and jetified-library-no-op-3.5.2-runtime (com.github.chuckerteam.chucker:library-no-op:3.5.2)

:wrench: Expected behavior

I expect that I can use chucker within different modules without compilation errors

:camera: Screenshots

The modules define chucker as following

This is how I define chucker in the library Screen Shot 2021-12-23 at 6 03 55 PM

Build types of the library Screen Shot 2021-12-23 at 6 04 29 PM

Build types of the app Screen Shot 2021-12-23 at 6 07 47 PM

The App has the following flavors Screen Shot 2021-12-23 at 6 08 55 PM

How I define the library inside the app Screen Shot 2021-12-23 at 6 09 43 PM

:iphone: Tech info

MiSikora commented 2 years ago

I'm using Chucker in an android library and also in another app that depended on the library.

If I understood this correctly, you're saying that Chucker is also applied in the application, but I don't see that from the attached screenshots. Am I getting something wrong?

Besides that, there shouldn't be any issues if a unique library variant is on a classpath of each build variant. Would you mind checking if it isn't a Gradle issue? A similar problem was reported in the past. https://github.com/ChuckerTeam/chucker/issues/666

If different library variants are applied from the library and directly to the application, then build failures are by design, and it is something you'd have to resolve on your part. Perhaps this thread might be helpful - https://github.com/ChuckerTeam/chucker/issues/362.

If none of this is helpful, you'd have to provide us with a sample project that reproduces this issue.

noureldeen-abouelkassem commented 2 years ago

If I understood this correctly, you're saying that Chucker is also applied in the application, but I don't see that from the attached screenshots. Am I getting something wrong?

you got it right

Would you mind checking if it isn't a Gradle issue?

I've checked it and it works well. there is no problem with Gradle.

I've read those two threads before none of them helped me in.

You can find a simple example here.

Please note that I am not able to add the credentials of the library because it is a library deployed on a private server.

A screenshot of the compilation error.

Screen Shot 2021-12-24 at 12 41 46 PM

MiSikora commented 2 years ago

I'm afraid everything works fine on my end. I cloned the sample and ran the following commands.

./gradlew :app:assembleStagingDebug
./gradlew :app:assembleProductionDebug
./gradlew :app:assembleStagingRelease
./gradlew :app:assembleProductionRelease

I also tried it by adding a dependency on :app:mylibrary below this snippet.

https://github.com/noureldeen-abouelkassem/MultiModulesChucker/blob/c8d082744be89edd5fb7b745e180cf8f2d2e8272/app/build.gradle#L61-L62

The whole issue looks like both library variants are being added to a single build variant (either due to Gradle issues or misconfiguration). I'm also not sure about the comment below.

implementation "io.halan.android:loan-forms:1.0.21" /* A library that use chucker 3.5.2
chucker dependencies is added as same as it is added here */

Do you mean that this library includes Chucker? I don't see it as a direct or transitive dependency on any of the classpaths. For example, look at dependencies from a productionDebug build variant.

productionDebugRuntimeClasspath - Runtime classpath of compilation 'productionDebug' (target  (androidJvm)).
+--- io.halan.android:loan-forms:1.0.21
|    +--- com.squareup.retrofit2:retrofit:2.9.0
|    |    \--- com.squareup.okhttp3:okhttp:3.14.9 -> 4.8.1 (*)
|    +--- androidx.databinding:viewbinding:7.0.2 (*)
|    +--- org.jetbrains.kotlin:kotlin-android-extensions-runtime:1.6.10
|    |    \--- org.jetbrains.kotlin:kotlin-stdlib:1.6.10 (*)
|    +--- org.jetbrains.kotlin:kotlin-stdlib:1.5.31 -> 1.6.10 (*)
|    +--- androidx.core:core-ktx:1.6.0 -> 1.7.0 (*)
|    +--- androidx.appcompat:appcompat:1.2.0 -> 1.4.0 (*)
|    +--- androidx.constraintlayout:constraintlayout:2.0.2 -> 2.1.2 (*)
|    +--- androidx.legacy:legacy-support-v4:1.0.0
|    |    +--- androidx.core:core:1.0.0 -> 1.7.0 (*)
|    |    +--- androidx.media:media:1.0.0
|    |    |    +--- androidx.annotation:annotation:1.0.0 -> 1.3.0
|    |    |    +--- androidx.core:core:1.0.0 -> 1.7.0 (*)
|    |    |    \--- androidx.versionedparcelable:versionedparcelable:1.0.0 -> 1.1.1 (*)
|    |    +--- androidx.legacy:legacy-support-core-utils:1.0.0 (*)
|    |    +--- androidx.legacy:legacy-support-core-ui:1.0.0
|    |    |    +--- androidx.annotation:annotation:1.0.0 -> 1.3.0
|    |    |    +--- androidx.core:core:1.0.0 -> 1.7.0 (*)
|    |    |    +--- androidx.legacy:legacy-support-core-utils:1.0.0 (*)
|    |    |    +--- androidx.customview:customview:1.0.0 -> 1.1.0 (*)
|    |    |    +--- androidx.viewpager:viewpager:1.0.0 (*)
|    |    |    +--- androidx.coordinatorlayout:coordinatorlayout:1.0.0 -> 1.1.0 (*)
|    |    |    +--- androidx.drawerlayout:drawerlayout:1.0.0 -> 1.1.1 (*)
|    |    |    +--- androidx.slidingpanelayout:slidingpanelayout:1.0.0
|    |    |    |    +--- androidx.annotation:annotation:1.0.0 -> 1.3.0
|    |    |    |    +--- androidx.core:core:1.0.0 -> 1.7.0 (*)
|    |    |    |    \--- androidx.customview:customview:1.0.0 -> 1.1.0 (*)
|    |    |    +--- androidx.interpolator:interpolator:1.0.0 (*)
|    |    |    +--- androidx.swiperefreshlayout:swiperefreshlayout:1.0.0 -> 1.1.0
|    |    |    |    +--- androidx.annotation:annotation:1.1.0 -> 1.3.0
|    |    |    |    +--- androidx.core:core:1.1.0 -> 1.7.0 (*)
|    |    |    |    \--- androidx.interpolator:interpolator:1.0.0 (*)
|    |    |    +--- androidx.asynclayoutinflater:asynclayoutinflater:1.0.0
|    |    |    |    +--- androidx.annotation:annotation:1.0.0 -> 1.3.0
|    |    |    |    \--- androidx.core:core:1.0.0 -> 1.7.0 (*)
|    |    |    \--- androidx.cursoradapter:cursoradapter:1.0.0 (*)
|    |    \--- androidx.fragment:fragment:1.0.0 -> 1.3.6 (*)
|    +--- androidx.lifecycle:lifecycle-extensions:2.2.0
|    |    +--- androidx.lifecycle:lifecycle-runtime:2.2.0 -> 2.4.0 (*)
|    |    +--- androidx.arch.core:core-common:2.1.0 (*)
|    |    +--- androidx.arch.core:core-runtime:2.1.0 (*)
|    |    +--- androidx.fragment:fragment:1.2.0 -> 1.3.6 (*)
|    |    +--- androidx.lifecycle:lifecycle-common:2.2.0 -> 2.4.0 (*)
|    |    +--- androidx.lifecycle:lifecycle-livedata:2.2.0 -> 2.3.1 (*)
|    |    +--- androidx.lifecycle:lifecycle-process:2.2.0 -> 2.4.0 (*)
|    |    +--- androidx.lifecycle:lifecycle-service:2.2.0
|    |    |    \--- androidx.lifecycle:lifecycle-runtime:2.2.0 -> 2.4.0 (*)
|    |    \--- androidx.lifecycle:lifecycle-viewmodel:2.2.0 -> 2.3.1 (*)
|    +--- com.google.android.material:material:1.4.0 (*)
|    +--- androidx.navigation:navigation-fragment-ktx:2.3.5
|    |    +--- androidx.navigation:navigation-fragment:2.3.5
|    |    |    +--- androidx.fragment:fragment:1.2.4 -> 1.3.6 (*)
|    |    |    \--- androidx.navigation:navigation-runtime:2.3.5
|    |    |         +--- androidx.navigation:navigation-common:2.3.5
|    |    |         |    +--- androidx.annotation:annotation:1.1.0 -> 1.3.0
|    |    |         |    +--- androidx.core:core:1.1.0 -> 1.7.0 (*)
|    |    |         |    \--- androidx.collection:collection:1.1.0 (*)
|    |    |         +--- androidx.activity:activity:1.1.0 -> 1.3.1 (*)
|    |    |         +--- androidx.lifecycle:lifecycle-viewmodel:2.2.0 -> 2.3.1 (*)
|    |    |         +--- androidx.savedstate:savedstate:1.0.0 -> 1.1.0 (*)
|    |    |         \--- androidx.lifecycle:lifecycle-viewmodel-savedstate:2.2.0 -> 2.3.1 (*)
|    |    +--- androidx.navigation:navigation-runtime-ktx:2.3.5
|    |    |    +--- androidx.navigation:navigation-runtime:2.3.5 (*)
|    |    |    +--- androidx.navigation:navigation-common-ktx:2.3.5
|    |    |    |    +--- androidx.navigation:navigation-common:2.3.5 (*)
|    |    |    |    +--- org.jetbrains.kotlin:kotlin-stdlib:1.3.71 -> 1.6.10 (*)
|    |    |    |    +--- androidx.core:core-ktx:1.1.0 -> 1.7.0 (*)
|    |    |    |    \--- androidx.collection:collection:1.1.0 (*)
|    |    |    +--- androidx.activity:activity-ktx:1.1.0 -> 1.2.4 (*)
|    |    |    +--- androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0 -> 2.3.1 (*)
|    |    |    \--- org.jetbrains.kotlin:kotlin-stdlib:1.3.71 -> 1.6.10 (*)
|    |    +--- androidx.fragment:fragment-ktx:1.2.4 -> 1.3.6 (*)
|    |    +--- androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0 -> 2.3.1 (*)
|    |    \--- org.jetbrains.kotlin:kotlin-stdlib:1.3.71 -> 1.6.10 (*)
|    +--- androidx.navigation:navigation-ui-ktx:2.3.5
|    |    +--- androidx.navigation:navigation-ui:2.3.5
|    |    |    +--- androidx.navigation:navigation-runtime:2.3.5 (*)
|    |    |    +--- androidx.customview:customview:1.1.0 (*)
|    |    |    +--- androidx.drawerlayout:drawerlayout:1.1.1 (*)
|    |    |    +--- com.google.android.material:material:1.0.0 -> 1.4.0 (*)
|    |    |    \--- androidx.transition:transition:1.3.0 (*)
|    |    +--- androidx.navigation:navigation-runtime-ktx:2.3.5 (*)
|    |    \--- org.jetbrains.kotlin:kotlin-stdlib:1.3.71 -> 1.6.10 (*)
|    +--- io.reactivex.rxjava2:rxjava:2.2.21
|    |    \--- org.reactivestreams:reactive-streams:1.0.3
|    +--- io.reactivex.rxjava2:rxandroid:2.1.1
|    |    \--- io.reactivex.rxjava2:rxjava:2.2.6 -> 2.2.21 (*)
|    +--- com.google.dagger:dagger:2.40
|    |    \--- javax.inject:javax.inject:1
|    +--- com.google.dagger:dagger-android-support:2.40
|    |    +--- com.google.dagger:dagger:2.40 (*)
|    |    +--- com.google.dagger:dagger-android:2.40
|    |    |    +--- com.google.dagger:dagger:2.40 (*)
|    |    |    +--- com.google.dagger:dagger-lint-aar:2.40
|    |    |    +--- androidx.annotation:annotation:1.2.0 -> 1.3.0
|    |    |    \--- javax.inject:javax.inject:1
|    |    +--- com.google.dagger:dagger-lint-aar:2.40
|    |    +--- androidx.activity:activity:1.3.1 (*)
|    |    +--- androidx.annotation:annotation:1.2.0 -> 1.3.0
|    |    +--- androidx.appcompat:appcompat:1.3.1 -> 1.4.0 (*)
|    |    +--- androidx.fragment:fragment:1.3.6 (*)
|    |    +--- androidx.lifecycle:lifecycle-common:2.3.1 -> 2.4.0 (*)
|    |    +--- androidx.lifecycle:lifecycle-viewmodel:2.3.1 (*)
|    |    +--- androidx.lifecycle:lifecycle-viewmodel-savedstate:2.3.1 (*)
|    |    \--- javax.inject:javax.inject:1
|    +--- androidx.swiperefreshlayout:swiperefreshlayout:1.1.0 (*)
|    +--- androidx.navigation:navigation-dynamic-features-fragment:2.3.5
|    |    +--- androidx.navigation:navigation-dynamic-features-runtime:2.3.5
|    |    |    +--- androidx.navigation:navigation-runtime-ktx:2.3.5 (*)
|    |    |    +--- com.google.android.play:core:1.9.1
|    |    |    \--- org.jetbrains.kotlin:kotlin-stdlib:1.3.71 -> 1.6.10 (*)
|    |    +--- androidx.navigation:navigation-fragment-ktx:2.3.5 (*)
|    |    \--- org.jetbrains.kotlin:kotlin-stdlib:1.3.71 -> 1.6.10 (*)
|    +--- androidx.fragment:fragment-ktx:1.3.6 (*)
|    +--- com.google.firebase:firebase-messaging:23.0.0
|    |    +--- androidx.collection:collection:1.0.0 -> 1.1.0 (*)
|    |    +--- androidx.core:core:1.0.0 -> 1.7.0 (*)
|    |    +--- com.google.android.datatransport:transport-api:3.0.0
|    |    |    \--- androidx.annotation:annotation:1.1.0 -> 1.3.0
|    |    +--- com.google.android.datatransport:transport-backend-cct:3.0.0 -> 3.1.0
|    |    |    +--- androidx.annotation:annotation:1.1.0 -> 1.3.0
|    |    |    +--- com.google.android.datatransport:transport-api:3.0.0 (*)
|    |    |    +--- com.google.android.datatransport:transport-runtime:3.1.0
|    |    |    |    +--- androidx.annotation:annotation:1.1.0 -> 1.3.0
|    |    |    |    +--- com.google.android.datatransport:transport-api:3.0.0 (*)
|    |    |    |    +--- com.google.firebase:firebase-encoders:17.0.0
|    |    |    |    |    \--- androidx.annotation:annotation:1.1.0 -> 1.3.0
|    |    |    |    +--- com.google.firebase:firebase-encoders-proto:16.0.0
|    |    |    |    |    +--- androidx.annotation:annotation:1.1.0 -> 1.3.0
|    |    |    |    |    \--- com.google.firebase:firebase-encoders:17.0.0 (*)
|    |    |    |    \--- javax.inject:javax.inject:1
|    |    |    +--- com.google.firebase:firebase-encoders:17.0.0 (*)
|    |    |    \--- com.google.firebase:firebase-encoders-json:18.0.0
|    |    |         +--- androidx.annotation:annotation:1.1.0 -> 1.3.0
|    |    |         \--- com.google.firebase:firebase-encoders:17.0.0 (*)
|    |    +--- com.google.android.datatransport:transport-runtime:3.0.0 -> 3.1.0 (*)
|    |    +--- com.google.android.gms:play-services-basement:17.0.0
|    |    |    +--- androidx.collection:collection:1.0.0 -> 1.1.0 (*)
|    |    |    +--- androidx.core:core:1.0.0 -> 1.7.0 (*)
|    |    |    \--- androidx.fragment:fragment:1.0.0 -> 1.3.6 (*)
|    |    +--- com.google.android.gms:play-services-cloud-messaging:17.0.0
|    |    |    +--- com.google.android.gms:play-services-basement:17.0.0 (*)
|    |    |    \--- com.google.android.gms:play-services-tasks:17.0.0
|    |    |         \--- com.google.android.gms:play-services-basement:17.0.0 (*)
|    |    +--- com.google.android.gms:play-services-stats:17.0.0
|    |    |    +--- androidx.legacy:legacy-support-core-utils:1.0.0 (*)
|    |    |    \--- com.google.android.gms:play-services-basement:17.0.0 (*)
|    |    +--- com.google.android.gms:play-services-tasks:17.0.0 (*)
|    |    +--- com.google.firebase:firebase-common:20.0.0
|    |    |    +--- com.google.android.gms:play-services-basement:17.0.0 (*)
|    |    |    +--- com.google.android.gms:play-services-tasks:17.0.0 (*)
|    |    |    \--- com.google.firebase:firebase-components:17.0.0
|    |    |         +--- androidx.annotation:annotation:1.1.0 -> 1.3.0
|    |    |         \--- com.google.firebase:firebase-annotations:16.0.0
|    |    +--- com.google.firebase:firebase-components:17.0.0 (*)
|    |    +--- com.google.firebase:firebase-datatransport:18.0.0
|    |    |    +--- androidx.annotation:annotation:1.1.0 -> 1.3.0
|    |    |    +--- com.google.android.datatransport:transport-api:3.0.0 (*)
|    |    |    +--- com.google.android.datatransport:transport-backend-cct:3.0.0 -> 3.1.0 (*)
|    |    |    +--- com.google.android.datatransport:transport-runtime:3.0.0 -> 3.1.0 (*)
|    |    |    +--- com.google.firebase:firebase-common:20.0.0 (*)
|    |    |    \--- com.google.firebase:firebase-components:17.0.0 (*)
|    |    +--- com.google.firebase:firebase-iid-interop:17.1.0
|    |    |    +--- com.google.android.gms:play-services-basement:17.0.0 (*)
|    |    |    \--- com.google.android.gms:play-services-tasks:17.0.0 (*)
|    |    +--- com.google.firebase:firebase-installations:17.0.0
|    |    |    +--- com.google.android.gms:play-services-tasks:17.0.0 (*)
|    |    |    +--- com.google.firebase:firebase-common:20.0.0 (*)
|    |    |    +--- com.google.firebase:firebase-components:17.0.0 (*)
|    |    |    \--- com.google.firebase:firebase-installations-interop:17.0.0
|    |    |         +--- com.google.android.gms:play-services-tasks:17.0.0 (*)
|    |    |         \--- com.google.firebase:firebase-annotations:16.0.0
|    |    +--- com.google.firebase:firebase-installations-interop:17.0.0 (*)
|    |    \--- com.google.firebase:firebase-measurement-connector:19.0.0
|    |         +--- com.google.android.gms:play-services-basement:17.0.0 (*)
|    |         \--- com.google.firebase:firebase-annotations:16.0.0
|    +--- com.google.firebase:firebase-crashlytics:18.2.4
|    |    +--- com.google.android.datatransport:transport-api:3.0.0 (*)
|    |    +--- com.google.android.datatransport:transport-backend-cct:3.1.0 (*)
|    |    +--- com.google.android.datatransport:transport-runtime:3.1.0 (*)
|    |    +--- com.google.android.gms:play-services-tasks:17.0.0 (*)
|    |    +--- com.google.firebase:firebase-annotations:16.0.0
|    |    +--- com.google.firebase:firebase-common:20.0.0 (*)
|    |    +--- com.google.firebase:firebase-components:17.0.0 (*)
|    |    +--- com.google.firebase:firebase-encoders:17.0.0 (*)
|    |    +--- com.google.firebase:firebase-encoders-json:18.0.0 (*)
|    |    +--- com.google.firebase:firebase-installations:17.0.0 (*)
|    |    +--- com.google.firebase:firebase-installations-interop:17.0.0 (*)
|    |    \--- com.google.firebase:firebase-measurement-connector:18.0.2 -> 19.0.0 (*)
|    +--- com.google.firebase:firebase-analytics:20.0.0
|    |    +--- com.google.android.gms:play-services-measurement:20.0.0
|    |    |    +--- androidx.collection:collection:1.0.0 -> 1.1.0 (*)
|    |    |    +--- androidx.legacy:legacy-support-core-utils:1.0.0 (*)
|    |    |    +--- com.google.android.gms:play-services-ads-identifier:17.0.0
|    |    |    |    \--- com.google.android.gms:play-services-basement:17.0.0 (*)
|    |    |    +--- com.google.android.gms:play-services-basement:17.0.0 (*)
|    |    |    +--- com.google.android.gms:play-services-measurement-base:20.0.0
|    |    |    |    \--- com.google.android.gms:play-services-basement:17.0.0 (*)
|    |    |    +--- com.google.android.gms:play-services-measurement-impl:20.0.0
|    |    |    |    +--- androidx.collection:collection:1.0.0 -> 1.1.0 (*)
|    |    |    |    +--- androidx.core:core:1.0.0 -> 1.7.0 (*)
|    |    |    |    +--- com.google.android.gms:play-services-ads-identifier:17.0.0 (*)
|    |    |    |    +--- com.google.android.gms:play-services-basement:17.0.0 (*)
|    |    |    |    +--- com.google.android.gms:play-services-measurement-base:20.0.0 (*)
|    |    |    |    \--- com.google.android.gms:play-services-stats:17.0.0 (*)
|    |    |    \--- com.google.android.gms:play-services-stats:17.0.0 (*)
|    |    +--- com.google.android.gms:play-services-measurement-api:20.0.0
|    |    |    +--- com.google.android.gms:play-services-ads-identifier:17.0.0 (*)
|    |    |    +--- com.google.android.gms:play-services-basement:17.0.0 (*)
|    |    |    +--- com.google.android.gms:play-services-measurement-base:20.0.0 (*)
|    |    |    +--- com.google.android.gms:play-services-measurement-sdk-api:20.0.0
|    |    |    |    +--- com.google.android.gms:play-services-basement:17.0.0 (*)
|    |    |    |    \--- com.google.android.gms:play-services-measurement-base:20.0.0 (*)
|    |    |    +--- com.google.android.gms:play-services-tasks:17.0.0 (*)
|    |    |    +--- com.google.firebase:firebase-common:20.0.0 (*)
|    |    |    +--- com.google.firebase:firebase-components:17.0.0 (*)
|    |    |    +--- com.google.firebase:firebase-installations:17.0.0 (*)
|    |    |    +--- com.google.firebase:firebase-installations-interop:17.0.0 (*)
|    |    |    \--- com.google.firebase:firebase-measurement-connector:19.0.0 (*)
|    |    \--- com.google.android.gms:play-services-measurement-sdk:20.0.0
|    |         +--- androidx.collection:collection:1.0.0 -> 1.1.0 (*)
|    |         +--- com.google.android.gms:play-services-basement:17.0.0 (*)
|    |         +--- com.google.android.gms:play-services-measurement-base:20.0.0 (*)
|    |         \--- com.google.android.gms:play-services-measurement-impl:20.0.0 (*)
|    +--- com.amplitude:android-sdk:2.25.2
|    +--- com.squareup.okhttp3:okhttp:4.8.0 -> 4.8.1 (*)
|    +--- io.halan.android:design-system:1.0.22
|    |    +--- org.jetbrains.kotlin:kotlin-android-extensions-runtime:1.3.60 -> 1.6.10 (*)
|    |    +--- org.jetbrains.kotlin:kotlin-stdlib:1.3.60 -> 1.6.10 (*)
|    |    +--- androidx.core:core-ktx:1.1.0 -> 1.7.0 (*)
|    |    +--- androidx.appcompat:appcompat:1.3.1 -> 1.4.0 (*)
|    |    +--- com.google.android.material:material:1.4.0 (*)
|    |    +--- androidx.swiperefreshlayout:swiperefreshlayout:1.1.0 (*)
|    |    +--- org.jetbrains.kotlin:kotlin-reflect:1.3.60 -> 1.4.31
|    |    |    \--- org.jetbrains.kotlin:kotlin-stdlib:1.4.31 -> 1.6.10 (*)
|    |    +--- com.github.bumptech.glide:glide:4.12.0
|    |    |    +--- com.github.bumptech.glide:gifdecoder:4.12.0
|    |    |    |    \--- androidx.annotation:annotation:1.0.0 -> 1.3.0
|    |    |    +--- com.github.bumptech.glide:disklrucache:4.12.0
|    |    |    +--- com.github.bumptech.glide:annotations:4.12.0
|    |    |    +--- androidx.fragment:fragment:1.0.0 -> 1.3.6 (*)
|    |    |    +--- androidx.vectordrawable:vectordrawable-animated:1.0.0 -> 1.1.0 (*)
|    |    |    \--- androidx.exifinterface:exifinterface:1.2.0 -> 1.3.3
|    |    |         \--- androidx.annotation:annotation:1.2.0 -> 1.3.0
|    |    \--- com.jakewharton.rxbinding4:rxbinding:4.0.0
|    |         +--- androidx.annotation:annotation:1.0.0 -> 1.3.0
|    |         +--- org.jetbrains.kotlin:kotlin-stdlib:1.3.72 -> 1.6.10 (*)
|    |         +--- io.reactivex.rxjava3:rxjava:3.0.3
|    |         |    \--- org.reactivestreams:reactive-streams:1.0.3
|    |         \--- io.reactivex.rxjava3:rxandroid:3.0.0
|    |              \--- io.reactivex.rxjava3:rxjava:3.0.0 -> 3.0.3 (*)
|    +--- io.coil-kt:coil:1.3.2
|    |    \--- io.coil-kt:coil-base:1.3.2
|    |         +--- org.jetbrains.kotlin:kotlin-parcelize-runtime:1.5.21
|    |         |    +--- org.jetbrains.kotlin:kotlin-stdlib:1.5.21 -> 1.6.10 (*)
|    |         |    \--- org.jetbrains.kotlin:kotlin-android-extensions-runtime:1.5.21 -> 1.6.10 (*)
|    |         +--- org.jetbrains.kotlin:kotlin-stdlib:1.5.21 -> 1.6.10 (*)
|    |         +--- org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.1 (*)
|    |         +--- androidx.lifecycle:lifecycle-common-java8:2.3.1 -> 2.4.0
|    |         |    +--- androidx.lifecycle:lifecycle-common:2.4.0 (*)
|    |         |    \--- androidx.annotation:annotation:1.1.0 -> 1.3.0
|    |         +--- com.squareup.okhttp3:okhttp:3.12.13 -> 4.8.1 (*)
|    |         +--- com.squareup.okio:okio:2.10.0 (*)
|    |         +--- androidx.annotation:annotation:1.2.0 -> 1.3.0
|    |         +--- androidx.appcompat:appcompat-resources:1.3.1 -> 1.4.0 (*)
|    |         +--- androidx.collection:collection-ktx:1.1.0 (*)
|    |         +--- androidx.core:core-ktx:1.6.0 -> 1.7.0 (*)
|    |         +--- androidx.exifinterface:exifinterface:1.3.3 (*)
|    |         \--- androidx.lifecycle:lifecycle-runtime:2.3.1 -> 2.4.0 (*)
|    +--- com.facebook.shimmer:shimmer:0.5.0
|    |    \--- androidx.annotation:annotation:1.0.1 -> 1.3.0
|    +--- com.squareup.retrofit2:converter-moshi:2.9.0
|    |    +--- com.squareup.retrofit2:retrofit:2.9.0 (*)
|    |    \--- com.squareup.moshi:moshi:1.8.0 -> 1.12.0
|    |         +--- com.squareup.okio:okio:2.10.0 (*)
|    |         \--- org.jetbrains.kotlin:kotlin-stdlib:1.4.31 -> 1.6.10 (*)
|    +--- com.squareup.retrofit2:adapter-rxjava2:2.9.0
|    |    +--- com.squareup.retrofit2:retrofit:2.9.0 (*)
|    |    +--- io.reactivex.rxjava2:rxjava:2.0.0 -> 2.2.21 (*)
|    |    \--- org.reactivestreams:reactive-streams:1.0.3
|    +--- com.squareup.okhttp3:logging-interceptor:4.8.1
|    |    \--- com.squareup.okhttp3:okhttp:4.8.1 (*)
|    +--- com.github.nisrulz:easydeviceinfo-base:2.4.1
|    |    +--- com.github.nisrulz:easydeviceinfo-common:2.4.1
|    |    \--- androidx.annotation:annotation:1.0.0 -> 1.3.0
|    +--- com.github.nisrulz:easydeviceinfo-ads:2.4.1
|    |    +--- com.github.nisrulz:easydeviceinfo-common:2.4.1
|    |    \--- com.google.android.gms:play-services-basement:11.8.0 -> 17.0.0 (*)
|    +--- com.squareup.moshi:moshi:1.12.0 (*)
|    +--- com.squareup.moshi:moshi-kotlin:1.12.0
|    |    +--- com.squareup.moshi:moshi:1.12.0 (*)
|    |    +--- org.jetbrains.kotlin:kotlin-reflect:1.4.31 (*)
|    |    \--- org.jetbrains.kotlin:kotlin-stdlib:1.4.31 -> 1.6.10 (*)
|    +--- com.squareup.moshi:moshi-adapters:1.8.0
|    |    \--- com.squareup.moshi:moshi:1.8.0 -> 1.12.0 (*)
|    \--- androidx.multidex:multidex:2.0.0
noureldeen-abouelkassem commented 2 years ago

That's so weird because the build.grade of the library has the two variants of the library as dependency the library and library-no-op.

It's weird also because I've run the dependencies command and it didn't show chucker as a dependency for my libray.

The project doesn't finish the build successful on my machine. I am using Gradle 7.0.4.

I also tried it by adding a dependency on :app:mylibrary below this snippet.

Yes, the project works well if I added the library module as a Dependency. By using implementation project in build.gradle.

However, if I used the dependency in the Gradle file it shows the error.

The whole issue looks like both library variants are being added to a single build variant

How could I add chucker to my library and use the library in a project that has chucker as a dependency also without adding the two variants to a single build variant?

I'm also not sure about the comment below.

As you can see I add chucker dependencies (library and library-no-op) into the library's build.gradle and also into the app. I am using my library by adding its dependency in build.gralde of the app but not with adding it as a dependency module (implementation project :app:mylibrary).

MiSikora commented 2 years ago

The project doesn't finish the build successful on my machine. I am using Gradle 7.0.4.

This would indicate that it's a problem with Gradle or some other setup of your local machine.

Sorry, but I'm getting really confused by the whole setup. I don't understand where each variant of Chucker comes from, and whether you control the whole build or is it some external source. Having said that, I'll try to answer one of your questions.

How could I add chucker to my library and use the library in a project that has chucker as a dependency without adding the two variants to a single build variant?

You could try to do something like this. But this may or may not work depending on the library configuration.

debugImplementation "library-that-includes-chucker"
releaseImplementation("library-that-includes-chucker") {
    exclude group: "com.github.chuckerteam.chucker", name: "library"
}
releaseImplementation "com.github.chuckerteam.chucker:library-no-op:3.5.2"

However, I think you should either make the library configurable by allowing the injection of interceptors (or ChuckerInterceptor specifically) or provide no-op as well. Though, having a library including different Chucker variants based on a build type should work as well.

noureldeen-abouelkassem commented 2 years ago

This is how I add chucker to my library

This is how I add chucker & my library dependencies in the app.

You could try to do something like this. But this may or may not work depending on the library configuration.

Yes, this is a workaround that will fit in my case since both my library and the app use the same version of chucker. But this won't help in any other case.

noureldeen-abouelkassem commented 2 years ago

I've solved the issue.

I edited maven publish to have 2 different maven publications instead of one. the first is for release and the second for debug.

Maven publish, script before.

afterEvaluate {
    publishing {
        publications {
            release(MavenPublication) {

                groupId GROUP_ID
                artifactId ARTIFACT_ID_RELEASE
                version VERSION_NAME

                from components.release
                artifact androidSourcesJar
                pom {
                    name = LIBRARY_NAME
                    description = DESCRIPTION
                    packaging = PACKAGING
                }
            }
         }

Maven publish script now

afterEvaluate {
    publishing {
        publications {
            release(MavenPublication) {

                groupId GROUP_ID
                artifactId ARTIFACT_ID_RELEASE
                version VERSION_NAME

                from components.release
                artifact androidSourcesJar
                pom {
                    name = LIBRARY_NAME
                    description = DESCRIPTION
                    packaging = PACKAGING
                }
            }

            debug(MavenPublication) {

                groupId GROUP_ID
                artifactId ARTIFACT_ID_DEBUG
                version VERSION_NAME

                from components.debug
                artifact androidSourcesJar
                pom {
                    name = LIBRARY_NAME
                    description = DESCRIPTION
                    packaging = PACKAGING
                }
            }
        }
     }

Now the library has 2 publications debug and release. and I use it this way.

    debugImplementation 'bla.bla.bla:bla-debug:1.0.24'
    releaseImplementation 'bla.bla.bla:bla-release:1.0.24'
noureldeen-abouelkassem commented 2 years ago

Now everything works fine, but I would say that it will be better if chucker has only one dependency. Thank you @MiSikora for your support and instant replies.

MiSikora commented 2 years ago

Glad to hear that you resolved the issue. 🎉

but I would say that it will be better if chucker has only one dependency

I agree in principle, but there are some valid concerns for not publishing the no-op variant. It basically boils down to ease of configuration, the overall UX, and security a bit. But if you feel strongly about it I encourage you to create an issue where it's more visible and everyone can participate in the discussion.

noureldeen-abouelkassem commented 2 years ago

Sure I will 😌