Duplicate Class error when adding com.google.android.gms:play-services-ads:22.0.0

1,043 views
Skip to first unread message

Abhishek Pundir

unread,
May 3, 2023, 1:50:39 AM5/3/23
to Google Mobile Ads SDK Developers

Hi Everyone, 

I was trying to add the google admob dependency in the project 

com.google.android.gms:play-services-ads:22.0.0) but getting 


Duplicate class com.google.android.gms.internal.measurement.zzbu 

found in modules jetified-play-services-measurement-17.4.3-runtime 

(com.google.android.gms:play-services-measurement:17.4.3) and 

jetified-play-services-measurement-sdk-api-20.1.2-runtime 

(com.google.android.gms:play-services-measurement-sdk-api:20.1.2) exception, 


I think this is getting logged as i am using com.google.firebase:firebase-core:17.4.3

as it is also adding com.google.android.gms internally which has a different version which gets imported by play-services-ads 

 

Does anyone knows how to resolve this?


Mobile Ads SDK Forum Advisor

unread,
May 3, 2023, 6:03:21 AM5/3/23
to abhishek...@gmail.com, google-adm...@googlegroups.com
Hello Abhishek,

Thank you for reaching out to us.

For us to properly troubleshoot your issue, kindly provide us the following information below privately:
  • Sample App
  • Steps to replicate
  • App ID
  • SDK Version
  • Complete Stack Trace Error
  • Device name and versions affected
You can provide the following details via reply privately to author option or directly provide it to the link below.

If the file(s) you are looking to share are less than 25mb in total you can attach them to this case on your next reply. If you are having trouble attaching your file to this case or if your file(s) are larger than 25mb, you can share your files with me by performing the following steps:

1. Navigate to

https://docs.google.com/forms/d/e/1FAIpQLSfkAiXMeYP-fw1W3Z-tT9uwmATEKO5X6S-th0gR2ezdKaaqfg/viewform?usp=pp_url&entry.400550049=Mobile+Ads+SDK&entry.460850823=5004Q00002l9ivRQAQ&entry.80707362=00177257

2. Fill out all fields, and attach your file(s).

3. Please reply back on this thread when you have uploaded your file(s). Please do not share this link.

Regards,
Google Logo Mobile Ads SDK Team


ref:_00D1U1174p._5004Q2l9ivR:ref

Abhishek Pundir

unread,
May 4, 2023, 4:22:10 AM5/4/23
to Google Mobile Ads SDK Developers
Sharing the link of the apk uploaded to github : https://github.com/pundirAbhishek/GoogleAdsIssueApp

Steps to replicate: 
Just compile the project and you will see the compile time error mentioned above. 

Mobile Ads SDK Forum Advisor

unread,
May 4, 2023, 6:40:43 AM5/4/23
to abhishek...@gmail.com, google-adm...@googlegroups.com
Hello Abhishek,

Thank you for the information.

To fix this issue, simply add this to your dependencies in your build.gradle: implementation platform('com.google.firebase:firebase-bom:30.1.0'). Feel free to reach back to us if you have any further inquiries or concerns.

Abhishek Pundir

unread,
May 5, 2023, 12:22:52 AM5/5/23
to Google Mobile Ads SDK Developers
Hi 
Thanks for the quick response but i have a couple of queries on this

1. Couldn't find a documentation regarding the same on why we would require to add this dependency. 
2. As per the documentation of the firebase-bom, it will keep the versions of all firebase libraries imported in sync, but as i am using a lot of individual firebase dependencies in my app, wouldn't this update those libraries version and create an issue at production?

Mobile Ads SDK Forum Advisor

unread,
May 5, 2023, 2:55:30 AM5/5/23
to abhishek...@gmail.com, google-adm...@googlegroups.com
Hello Abhishek,

With regards to your inquiry, the Firebase Android BoM (Bill of Materials) enables you to manage all your Firebase library versions by specifying only one version — the BoM's version.

When you use the Firebase BoM in your app, the BoM automatically pulls in the individual library versions mapped to BoM's version. All the individual library versions will be compatible. When you update the BoM's version in your app, all the Firebase libraries that you use in your app will update to the versions mapped to that BoM version.

The BoM acts like a sort of manifest for all your Firebase libraries. This prevents Duplicate Class error you encountered. This will not cause problems to those libraries version and create an issue at production. You can read more in this documentation for more information (https://firebase.google.com/docs/android/learn-more#bom)

Reply all
Reply to author
Forward
0 new messages