title: How to fix `duplicate class com.google.firebase.components`?
body: <p>I started to use the MLKit barcode scanner in my project and get the <code>Duplicate class</code> error when trying to run the app.
  Also, I tried to <code>exclude firebase-common</code> and <code>exclude firebase-components</code>, but it didn't help, because it breaks push notification or MLKit scanner.</p>
  <p>From Firebase and Google we use those dependencies:</p>
  <pre><code>playServices: [
     base     : &quot;com.google.android.gms:play-services-base:17.0.0&quot;,
     maps     : &quot;com.google.android.gms:play-services-maps:17.0.0&quot;,
     location : &quot;com.google.android.gms:play-services-location:17.0.0&quot;,
     safetynet: &quot;com.google.android.gms:play-services-safetynet:17.0.0&quot;,
  ],
  firebase: [
     messaging: &quot;com.google.firebase:firebase-messaging:20.0.0&quot;,
     barcode: &quot;com.google.mlkit:barcode-scanning:16.0.0&quot;
  ]
  </code></pre>
  <pre><code>Duplicate class com.google.firebase.components.AbstractComponentContainer found in modules jetified-firebase-common-19.0.0-runtime.jar (com.google.firebase:firebase-common:19.0.0) and jetified-firebase-components-16.0.0-runtime.jar (com.google.firebase:firebase-components:16.0.0)
  Duplicate class com.google.firebase.components.Component found in modules jetified-firebase-common-19.0.0-runtime.jar (com.google.firebase:firebase-common:19.0.0) and jetified-firebase-components-16.0.0-runtime.jar (com.google.firebase:firebase-components:16.0.0)
  Duplicate class com.google.firebase.components.Component$$Lambda$1 found in modules jetified-firebase-common-19.0.0-runtime.jar (com.google.firebase:firebase-common:19.0.0) and jetified-firebase-components-16.0.0-runtime.jar (com.google.firebase:firebase-components:16.0.0)
  Duplicate class com.google.firebase.components.Component$$Lambda$2 found in modules jetified-firebase-common-19.0.0-runtime.jar (com.google.firebase:firebase-common:19.0.0) and jetified-firebase-components-16.0.0-runtime.jar (com.google.firebase:firebase-components:16.0.0)
  Duplicate class com.google.firebase.components.Component$$Lambda$3 found in modules jetified-firebase-common-19.0.0-runtime.jar (com.google.firebase:firebase-common:19.0.0) and jetified-firebase-components-16.0.0-runtime.jar (com.google.firebase:firebase-components:16.0.0)
  Duplicate class com.google.firebase.components.Component$1 found in modules jetified-firebase-common-19.0.0-runtime.jar (com.google.firebase:firebase-common:19.0.0) and jetified-firebase-components-16.0.0-runtime.jar (com.google.firebase:firebase-components:16.0.0)
  Duplicate class com.google.firebase.components.Component$Builder found in modules jetified-firebase-common-19.0.0-runtime.jar (com.google.firebase:firebase-common:19.0.0) and jetified-firebase-components-16.0.0-runtime.jar (com.google.firebase:firebase-components:16.0.0)
  Duplicate class com.google.firebase.components.ComponentContainer found in modules jetified-firebase-common-19.0.0-runtime.jar (com.google.firebase:firebase-common:19.0.0) and jetified-firebase-components-16.0.0-runtime.jar (com.google.firebase:firebase-components:16.0.0)
  Duplicate class com.google.firebase.components.ComponentDiscovery found in modules jetified-firebase-common-19.0.0-runtime.jar (com.google.firebase:firebase-common:19.0.0) and jetified-firebase-components-16.0.0-runtime.jar (com.google.firebase:firebase-components:16.0.0)
  Duplicate class com.google.firebase.components.ComponentDiscovery$1 found in modules jetified-firebase-common-19.0.0-runtime.jar (com.google.firebase:firebase-common:19.0.0) and jetified-firebase-components-16.0.0-runtime.jar (com.google.firebase:firebase-components:16.0.0)
  Duplicate class com.google.firebase.components.ComponentDiscovery$MetadataRegistrarNameRetriever found in modules jetified-firebase-common-19.0.0-runtime.jar (com.google.firebase:firebase-common:19.0.0) and jetified-firebase-components-16.0.0-runtime.jar (com.google.firebase:firebase-components:16.0.0)
  Duplicate class com.google.firebase.components.ComponentDiscovery$RegistrarNameRetriever found in modules jetified-firebase-common-19.0.0-runtime.jar (com.google.firebase:firebase-common:19.0.0) and jetified-firebase-components-16.0.0-runtime.jar (com.google.firebase:firebase-components:16.0.0)
  
  and more classes ...
  </code></pre>