How can I resolve a 'duplicate class' error related to Android libraries?

Responsive Ad Header

Question

Grade: Education Subject: Support
How can I resolve a 'duplicate class' error related to Android libraries?
Asked by:
73 Viewed 73 Answers

Answer (73)

Best Answer
(460)
For Android projects, a common cause is including the same Android support or Jetpack library multiple times. Check your `build.gradle` files (module and project level) for redundant dependencies. Use Android Studio's dependency analyzer (Analyze > Analyze Dependencies) to visually identify duplicate dependencies. Consider using `implementation` instead of `api` for dependencies where possible, as `api` transitively exposes dependencies to other modules.