Duplicate class build error when adding firebase with play-services-ads

I have tried to connect firebase to my existing android project with Admob integration and I got the following error stack when build the project.

Duplicate class com.google.android.gms.internal.measurement.zzdi found in modules classes.jar (com.google.android.gms:play-services-appinvite:16.0.4) and classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0)
Duplicate class com.google.android.gms.internal.measurement.zzdj found in modules classes.jar (com.google.android.gms:play-services-appinvite:16.0.4) and classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0)
Duplicate class com.google.android.gms.internal.measurement.zzdk found in modules classes.jar (com.google.android.gms:play-services-appinvite:16.0.4) and classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0)
Duplicate class com.google.android.gms.internal.measurement.zzdl found in modules classes.jar (com.google.android.gms:play-services-appinvite:16.0.4) and classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0)
Duplicate class com.google.android.gms.internal.measurement.zzdm found in modules classes.jar (com.google.android.gms:play-services-appinvite:16.0.4) and classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0)
Duplicate class com.google.android.gms.internal.measurement.zzdn found in modules classes.jar (com.google.android.gms:play-services-appinvite:16.0.4) and classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0)
Duplicate class com.google.android.gms.internal.measurement.zzdo found in modules classes.jar (com.google.android.gms:play-services-appinvite:16.0.4) and classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0)
Duplicate class com.google.android.gms.internal.measurement.zzdp found in modules classes.jar (com.google.android.gms:play-services-appinvite:16.0.4) and classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0)
Duplicate class com.google.android.gms.internal.measurement.zzdq found in modules classes.jar (com.google.android.gms:play-services-appinvite:16.0.4) and classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0)
Duplicate class com.google.android.gms.internal.measurement.zzdr found in modules classes.jar (com.google.android.gms:play-services-appinvite:16.0.4) and classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0)
Duplicate class com.google.android.gms.internal.measurement.zzds found in modules classes.jar (com.google.android.gms:play-services-appinvite:16.0.4) and classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0)
Duplicate class com.google.android.gms.internal.measurement.zzdt found in modules classes.jar (com.google.android.gms:play-services-appinvite:16.0.4) and classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0)
Duplicate class com.google.android.gms.internal.measurement.zzdu found in modules classes.jar (com.google.android.gms:play-services-appinvite:16.0.4) and classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0)
Duplicate class com.google.android.gms.internal.measurement.zzdv found in modules classes.jar (com.google.android.gms:play-services-appinvite:16.0.4) and classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0)
Duplicate class com.google.android.gms.internal.measurement.zzdw found in modules classes.jar (com.google.android.gms:play-services-appinvite:16.0.4) and classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0)
Duplicate class com.google.android.gms.internal.measurement.zzfq found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics:16.0.4)
Duplicate class com.google.android.gms.internal.measurement.zzfr found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics:16.0.4)
Duplicate class com.google.android.gms.internal.measurement.zzfs found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics:16.0.4)
Duplicate class com.google.android.gms.internal.measurement.zzft found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics:16.0.4)
Duplicate class com.google.android.gms.internal.measurement.zzfu found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics:16.0.4)
Duplicate class com.google.android.gms.internal.measurement.zzfv found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics:16.0.4)
Duplicate class com.google.android.gms.internal.measurement.zzfw found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics:16.0.4)
Duplicate class com.google.android.gms.internal.measurement.zzfx found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics:16.0.4)
Duplicate class com.google.android.gms.internal.measurement.zzfy found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics:16.0.4)
Duplicate class com.google.android.gms.internal.measurement.zzfz found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics:16.0.4)
Duplicate class com.google.android.gms.internal.measurement.zzga found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics:16.0.4)
Duplicate class com.google.android.gms.internal.measurement.zzgb found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics:16.0.4)
Duplicate class com.google.android.gms.internal.measurement.zzgc found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics:16.0.4)
Duplicate class com.google.android.gms.internal.measurement.zzgd found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics:16.0.4)
Duplicate class com.google.android.gms.internal.measurement.zzge found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics:16.0.4)
Duplicate class com.google.android.gms.internal.measurement.zzgf found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics:16.0.4)
Duplicate class com.google.android.gms.internal.measurement.zzgg found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics:16.0.4)
Duplicate class com.google.android.gms.internal.measurement.zzgh found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics:16.0.4)
Duplicate class com.google.android.gms.internal.measurement.zzgi found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics:16.0.4)
Duplicate class com.google.android.gms.internal.measurement.zzgj found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics:16.0.4)
Duplicate class com.google.android.gms.internal.measurement.zzgk found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics:16.0.4)
Duplicate class com.google.android.gms.internal.measurement.zzgl found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics:16.0.4)
Duplicate class com.google.android.gms.internal.measurement.zzu found in modules classes.jar (com.google.android.gms:play-services-measurement-sdk-api:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:16.2.2)
Duplicate class com.google.android.gms.internal.measurement.zzv found in modules classes.jar (com.google.android.gms:play-services-measurement-sdk-api:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:16.2.2)
Duplicate class com.google.android.gms.internal.measurement.zzw found in modules classes.jar (com.google.android.gms:play-services-measurement-base:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:16.2.2)
Duplicate class com.google.android.gms.measurement.AppMeasurement found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:16.2.2)
Duplicate class com.google.android.gms.measurement.AppMeasurement$ConditionalUserProperty found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:16.2.2)
Duplicate class com.google.android.gms.measurement.AppMeasurement$Event found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:16.2.2)
Duplicate class com.google.android.gms.measurement.AppMeasurement$EventInterceptor found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:16.2.2)
Duplicate class com.google.android.gms.measurement.AppMeasurement$OnEventListener found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:16.2.2)
Duplicate class com.google.android.gms.measurement.AppMeasurement$Param found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:16.2.2)
Duplicate class com.google.android.gms.measurement.AppMeasurement$UserProperty found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:16.2.2)
Duplicate class com.google.android.gms.measurement.AppMeasurementContentProvider found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:16.2.2)
Duplicate class com.google.android.gms.measurement.AppMeasurementInstallReferrerReceiver found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:16.2.2)
Duplicate class com.google.android.gms.measurement.AppMeasurementJobService found in modules classes.jar (com.google.android.gms:play-services-measurement:17.0.0) and classes.jar (com.google.firebase:firebase-analytics:16.0.4)
Duplicate class com.google.android.gms.measurement.AppMeasurementReceiver found in modules classes.jar (com.google.android.gms:play-services-measurement:17.0.0) and classes.jar (com.google.firebase:firebase-analytics:16.0.4)
Duplicate class com.google.android.gms.measurement.AppMeasurementService found in modules classes.jar (com.google.android.gms:play-services-measurement:17.0.0) and classes.jar (com.google.firebase:firebase-analytics:16.0.4)
Duplicate class com.google.android.gms.measurement.internal.zza found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:16.2.2)
Duplicate class com.google.android.gms.measurement.internal.zzaa found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:16.2.2)
Duplicate class com.google.android.gms.measurement.internal.zzab found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:16.2.2)
Duplicate class com.google.android.gms.measurement.internal.zzac found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:16.2.2)
Duplicate class com.google.android.gms.measurement.internal.zzad found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:16.2.2)
Duplicate class com.google.android.gms.measurement.internal.zzae found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:16.2.2)
Duplicate class com.google.android.gms.measurement.internal.zzaf found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:16.2.2)
Duplicate class com.google.android.gms.measurement.internal.zzag found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:16.2.2)
Duplicate class com.google.android.gms.measurement.internal.zzah found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:16.2.2)
Duplicate class com.google.android.gms.measurement.internal.zzai found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:16.2.2)
Duplicate class com.google.android.gms.measurement.internal.zzaj found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:16.2.2)
Duplicate class com.google.android.gms.measurement.internal.zzak found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:16.2.2)
Duplicate class com.google.android.gms.measurement.internal.zzal found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:16.2.2)
Duplicate class com.google.android.gms.measurement.internal.zzam found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:16.2.2)
Duplicate class com.google.android.gms.measurement.internal.zzan found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:16.2.2)
Duplicate class com.google.android.gms.measurement.internal.zzao found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:16.2.2)
Duplicate class com.google.android.gms.measurement.internal.zzap found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:16.2.2)
Duplicate class com.google.android.gms.measurement.internal.zzaq found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:16.2.2)
Duplicate class com.google.android.gms.measurement.internal.zzar found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:16.2.2)
Duplicate class com.google.android.gms.measurement.internal.zzas found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:16.2.2)
Duplicate class com.google.android.gms.measurement.internal.zzat found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics:16.0.4)
Duplicate class com.google.android.gms.measurement.internal.zzau found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics:16.0.4)
Duplicate class com.google.android.gms.measurement.internal.zzav found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics:16.0.4)
Duplicate class com.google.android.gms.measurement.internal.zzaw found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics:16.0.4)
Duplicate class com.google.android.gms.measurement.internal.zzax found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics:16.0.4)
Duplicate class com.google.android.gms.measurement.internal.zzay found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics:16.0.4)
Duplicate class com.google.android.gms.measurement.internal.zzaz found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics:16.0.4)
Duplicate class com.google.android.gms.measurement.internal.zzb found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:16.2.2)
Duplicate class com.google.android.gms.measurement.internal.zzba found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:16.2.2)
Duplicate class com.google.android.gms.measurement.internal.zzbb found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:16.2.2)
Duplicate class com.google.android.gms.measurement.internal.zzbc found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:16.2.2)
Duplicate class com.google.android.gms.measurement.internal.zzbd found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:16.2.2)
Duplicate class com.google.android.gms.measurement.internal.zzbe found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:16.2.2)
Duplicate class com.google.android.gms.measurement.internal.zzbf found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:16.2.2)
Duplicate class com.google.android.gms.measurement.internal.zzbg found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:16.2.2)
Duplicate class com.google.android.gms.measurement.internal.zzbh found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:16.2.2)
Duplicate class com.google.android.gms.measurement.internal.zzbi found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:16.2.2)
Duplicate class com.google.android.gms.measurement.internal.zzbj found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:16.2.2)
Duplicate class com.google.android.gms.measurement.internal.zzbk found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:16.2.2)
Duplicate class com.google.android.gms.measurement.internal.zzbl found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:16.2.2)
Duplicate class com.google.android.gms.measurement.internal.zzbm found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:16.2.2)
Duplicate class com.google.android.gms.measurement.internal.zzbn found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics:16.0.4)
Duplicate class com.google.android.gms.measurement.internal.zzbo found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:16.2.2)
Duplicate class com.google.android.gms.measurement.internal.zzbp found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:16.2.2)
Duplicate class com.google.android.gms.measurement.internal.zzbq found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:16.2.2)
Duplicate class com.google.android.gms.measurement.internal.zzbr found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:16.2.2)
Duplicate class com.google.android.gms.measurement.internal.zzbs found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:16.2.2)
Duplicate class com.google.android.gms.measurement.internal.zzbt found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:16.2.2)
Duplicate class com.google.android.gms.measurement.internal.zzbu found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:16.2.2)
Duplicate class com.google.android.gms.measurement.internal.zzbv found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics:16.0.4)
Duplicate class com.google.android.gms.measurement.internal.zzbw found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics:16.0.4)
Duplicate class com.google.android.gms.measurement.internal.zzbx found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics:16.0.4)
Duplicate class com.google.android.gms.measurement.internal.zzby found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics:16.0.4)
Duplicate class com.google.android.gms.measurement.internal.zzbz found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics:16.0.4)
Duplicate class com.google.android.gms.measurement.internal.zzc found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:16.2.2)
Duplicate class com.google.android.gms.measurement.internal.zzca found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics:16.0.4)
Duplicate class com.google.android.gms.measurement.internal.zzcb found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics:16.0.4)
Duplicate class com.google.android.gms.measurement.internal.zzcc found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics:16.0.4)
Duplicate class com.google.android.gms.measurement.internal.zzcd found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics:16.0.4)
Duplicate class com.google.android.gms.measurement.internal.zzce found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics:16.0.4)
Duplicate class com.google.android.gms.measurement.internal.zzcf found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics:16.0.4)
Duplicate class com.google.android.gms.measurement.internal.zzcg found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics:16.0.4)
Duplicate class com.google.android.gms.measurement.internal.zzch found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics:16.0.4)

Basically I want to add Admob rewards adz in my app so I had to use implementation 'com.google.android.gms:play-services-ads:18.2.0'

It seems to be there is a complict with implementation 'com.google.android.gms:play-services-ads:18.2.0' and implementation 'com.google.firebase:firebase-invites:16.0.4'

Gradle file

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

android {
    compileSdkVersion 29
    defaultConfig {
        applicationId "com.vivo.proj.firebase_example"
        minSdkVersion 23
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'com.google.firebase:firebase-invites:16.0.4'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'

    implementation 'com.google.android.gms:play-services-auth:17.0.0'
    implementation 'com.google.android.gms:play-services-ads:18.2.0'

    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}

Could please help me to solve this issue.

1 answer

  • answered 2019-12-08 18:27 Peter Haddad

    From the docs:

    Firebase Invites is deprecated. On January 24th, 2020, we will discontinue support for Firebase Invites. Instead, use Firebase Dynamic Links for a custom sharing solution

    Use the following dependency :

    implementation 'com.google.firebase:firebase-dynamic-links:19.0.0'
    

    https://firebase.google.com/support/release-notes/android