1

I'm building a library for other developers to use in another projects, let's call it SDK.

My SDK uses the Android class Worker to schedule background jobs, and I'm using this library:

androidx.work:work-runtime:2.2.0

One of the developers that uses SDK had a problem of duplicate classes when implemented my SDK, because another library was importing the same classes of work-runtime. But not in the same package:

android.arch.work:work-runtime:1.0.1

If I ask the developer to use exclude when implementing my SDK, then it will try to use the classes with a lower version (1.0.1), so it'll be in another version that I didn't tested. I already tried this.

What can I do to resolve this duplicate problem because both libraries have the same classes? It's possible to maintain both libraries with different versions in separate scopes?

This is the error:

  Duplicate class androidx.work.BackoffPolicy found in modules classes.jar (android.arch.work:work-runtime:1.0.1) and classes.jar (androidx.work:work-runtime:2.2.0)
  Duplicate class androidx.work.Configuration found in modules classes.jar (android.arch.work:work-runtime:1.0.1) and classes.jar (androidx.work:work-runtime:2.2.0)
  Duplicate class androidx.work.Configuration$Builder found in modules classes.jar (android.arch.work:work-runtime:1.0.1) and classes.jar (androidx.work:work-runtime:2.2.0)
  Duplicate class androidx.work.Constraints found in modules classes.jar (android.arch.work:work-runtime:1.0.1) and classes.jar (androidx.work:work-runtime:2.2.0)
  Duplicate class androidx.work.Constraints$Builder found in modules classes.jar (android.arch.work:work-runtime:1.0.1) and classes.jar (androidx.work:work-runtime:2.2.0)
  Duplicate class androidx.work.ContentUriTriggers found in modules classes.jar (android.arch.work:work-runtime:1.0.1) and classes.jar (androidx.work:work-runtime:2.2.0)
  ...

Thank you!

Lucas Reis
  • 441
  • 2
  • 9

0 Answers0