Search Unity

Build Errors - Duplicate Classes

Discussion in 'Unity Ads & User Acquisition' started by raiden, Feb 24, 2020.

  1. raiden

    raiden

    Joined:
    Feb 8, 2009
    Posts:
    333
    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.
    Screenshot 2020-02-23 20.10.00.png

    Thank you for your help.

    Larry
     
  2. raiden

    raiden

    Joined:
    Feb 8, 2009
    Posts:
    333
    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
     
  3. sbankhead

    sbankhead

    Unity Technologies

    Joined:
    Jul 27, 2014
    Posts:
    97
    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.
     
  4. raiden

    raiden

    Joined:
    Feb 8, 2009
    Posts:
    333
    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.
    Screenshot 2020-02-29 18.48.46.png Thanks
     
    Last edited: Mar 1, 2020
  5. kyle-unity

    kyle-unity

    Unity Technologies

    Joined:
    Jan 6, 2020
    Posts:
    336
    @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.
     
  6. Asenderov

    Asenderov

    Joined:
    Dec 6, 2015
    Posts:
    15
    @kr-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:

    1. 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".
    2. 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.
    upload_2020-7-2_18-29-9.png
     

    Attached Files:

  7. kyle-unity

    kyle-unity

    Unity Technologies

    Joined:
    Jan 6, 2020
    Posts:
    336
    @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.
     
  8. Asenderov

    Asenderov

    Joined:
    Dec 6, 2015
    Posts:
    15
    @kr-unity That's unfortunate! Thanks for the quick response!