Build Errors - Duplicate Classes

I would really like to learn how to resolve this. I am using the GoogleMobileAds-v4.2.1 & The latest UnityAds package on the Asset Store. The goal is to display Admob & UnityAds.

Anyone with experience on removing or resolving duplicate classes, I would be greatly appreciative of you could explain to me how to correct this.

This is direct form Android Studio.

Thank you for your help.

Larry

I have resolved this by opening up the build.gradle file in Android Studio, and commenting out the line with unity-ads. Do this, re-sync, and build to your device, and it works fine now.

Larry

You should not be manually including the unity ads sdk when using mediation. the mediation stack should import the unity ads sdk on its own. this is why you were getting duplicate definitions.

I’m am not understanding what you by not including manually include the unity ads sdk using mediation? I’ve imported the Unity Ads sdk from the asset store, I am also using the Google Admob sdk so that I can combine Admob & Unity ads.

Any help would be appreciated I am still struggling with this, basically although I am calling the ads service to initialize and calling a bottom banner to display, I get no test ad.

This is what is showing in my console, I do not know how to fix this in Unity.

Thanks

@raiden The AdMob SDK already includes the Unity Ads SDK, so when you also install Unity Ads from the asset store, it results in the Unity Ads SDK being present in your project in two different places - giving you duplicate class errors.

@kyle-unity
I’m using the AdMob SDK, and I’ve integrated Unity in the mediation with AdMob, the only issue I’m having is that it doesn’t seem like AdMob does support non-rewarded videos, and I would like to have them in my game, so below are the two scenarios:

  • If I don’t enable Unity Ads in the Services, when I add the “using UnityEngine.Advertisements;” and try to use Advertisement.Initialize(store_id, true), it doesn’t recognize the “Advertisement”.
  • If I do enable the Unity Ads in the Services, it eliminates the issue in bullet point 1, and tests perfectly, but when building the projects, it shows the duplicate classes.

Even when I try to search for the using Uni…Advertis… it doesn’t show up. I’ve also tried the old one instead, the Monetization, and it didn’t work as well.
6049595--654236--upload_2020-7-2_18-29-9.png

6049595--654227--upload_2020-7-2_18-21-59.png

@Asenderov Unfortunately what you’re looking to do here isn’t possible. The AdMob SDK already includes the Unity Ads SDK so trying to include our SDK yourself will always introduce compiler errors.

Even if it worked, you would not be able to initialize the Unity Ads SDK twice in one game session. And even if that worked, there would likely be unexpected behaviour - potentially causing incorrect data or even crashes.

@kyle-unity That’s unfortunate! Thanks for the quick response!