Search Unity

[Unity 5.2] The imported type `UnityEngine.Advertisements.ShowResult' is defined multiple times

Discussion in 'Unity Ads & User Acquisition' started by elmar1028, Sep 8, 2015.

  1. elmar1028

    elmar1028

    Joined:
    Nov 21, 2013
    Posts:
    2,359
    Hello,

    Today I have upgraded my project to Unity 5.2.

    I have issues with UnityAds as it gives me errors:

    error CS0433: The imported type `UnityEngine.Advertisements.Advertisement' is defined multiple times
    error CS0433: The imported type `UnityEngine.Advertisements.ShowResult' is defined multiple times
    error CS0433: The imported type `UnityEngine.Advertisements.ShowOptions' is defined multiple times

    Any ideas how to fix it?

    Thanks in advance! :)
     
    iterreno likes this.
  2. Munchy2007

    Munchy2007

    Joined:
    Jun 16, 2013
    Posts:
    1,735
    Same problem here, and this is after I have imported Unity Ads from the asset store into a completely new project.
     
  3. elmar1028

    elmar1028

    Joined:
    Nov 21, 2013
    Posts:
    2,359
    I solved the problem! UnityAds is implemented into Unity Editor starting 5.2 (just like other Unity plugins).

    You must remove UnityAds asset from the project.
     
  4. jpv1234

    jpv1234

    Joined:
    Dec 5, 2014
    Posts:
    89
    how are we supposed to work now in Unity ads? I can't find any type of documentation for 5.2
     
    Thorny2000 likes this.
  5. Munchy2007

    Munchy2007

    Joined:
    Jun 16, 2013
    Posts:
    1,735
    As elmar1028 pointed out, the ads system is now built into Unity, so there's no need to download it from the asset store. Furthermore once you've enabled ads in the services Window and linked your app to it, you don't even need to init() the system with your app ID etc. as this happens automatically.

    The two code examples they provide in the services window will work as they are, however you can still refer to the live training video for further information, as pretty much everything apart from the installation and initialisation bits is still relevant.

    One thing that might cause confusion, is that you need to switch to Android or IOS build type, or you'll get errors when you run the program. This caused me some head scratching for a while :p
     
  6. jpv1234

    jpv1234

    Joined:
    Dec 5, 2014
    Posts:
    89
    I don't know if its only me, but if I try to enable the Unity ads service in the services window, it still says off. Any idea why this can be?
     
  7. jpv1234

    jpv1234

    Joined:
    Dec 5, 2014
    Posts:
    89
    Maybe this helps someone. If you removed all the files, remember to restart Unity. This way, the services panel will work correctly. Thanks for your help Munchy2007
     
    eDevGames likes this.
  8. rasmus-unity

    rasmus-unity

    Moderator

    Joined:
    Aug 15, 2014
    Posts:
    1,312
    Good you solved it yourself. We do have some documentation for enabling Ads in 5.2 using the connect window at http://docs.unity3d.com/Manual/UnityAdsHowTo.html.

    However, you should also be able to continue using the Asset Store Ads package in 5.2, however I've seen that it can require a reimport of assets in Unity to have it detect that Asset Store package should be used.

    /Rasmus
     
  9. BenouKat

    BenouKat

    Joined:
    Feb 29, 2012
    Posts:
    222
    Hi,

    I removed all the UnityAds folder (Standard Assets, Standard Assets Editor, iOS one and Android one), restarted Unity, but the "type or namespace ShowResult" still couldn't be found (as every UnityEngine.Advertisments class). Am i forgot something ?

    Thanks
     
  10. elmar1028

    elmar1028

    Joined:
    Nov 21, 2013
    Posts:
    2,359
    There is a free plugin – Package Uninstaller. I used it to remove UnityAds plugin and it worked.

    If it still doesn't work then restart Unity
     
    HSP_Studio likes this.
  11. BenouKat

    BenouKat

    Joined:
    Feb 29, 2012
    Posts:
    222
    I found it : allowPrecache and a parameter in ShowResult function was removed in the last SDK, cause my compiler, well, not compile, and showing a bad error instead.

    Solved !

    Now my Unity 5.2 is instant crashing when I hit play (works fine in 5.1.3) but this is another subject... :D
     
  12. ElBuho

    ElBuho

    Joined:
    Mar 9, 2015
    Posts:
    32
    Hi all.

    I had the same problem and fortunately I could solve with the elmar1028 advice, uninstalling the unity ads plugin with Package Installer.
    But now, with the new UnityAds implemented into Unity Editor, the ads loads slower than before.
    Does anyone else have this problem?
    Can it be because now we can't use allowPrecache?

    Thank you.
     
  13. elmar1028

    elmar1028

    Joined:
    Nov 21, 2013
    Posts:
    2,359
    As far as I know allowPrecache doesn't work at all.
    Assigning a value doesn't change anything as it always returns true.
    Found here
     
  14. AbdallahElshabrawy

    AbdallahElshabrawy

    Joined:
    Jan 8, 2013
    Posts:
    3
    This is what i did:

    - Remove unity ads plugin (Plugins and standard asset folders).
    - Linked my game with ads through unity service window.
    - Remove unity ads initialization from my code "Advertisement.Initialize (GameID)".
     
    PSchalley and elmar1028 like this.
  15. alternative_richie

    alternative_richie

    Joined:
    Sep 4, 2014
    Posts:
    15
    Hey, thanks The Ballo for mentioning removing the initialization code. What a monkey I am, scratched my head because I was getting an Advertisement.Initialize error! It doesn't need to be there anymore, removed it, fixed! Cheers.
     
  16. actraiser3

    actraiser3

    Joined:
    Sep 11, 2014
    Posts:
    28
    Is it still possible to initialize UnityAds at Runtime? I need to provide different IDs depending on the type of version I create from the project. At Boot I check some environment settings and decide if I want to initialize version A or Version B of the project. This worked fine with the Plugin-Solution. How is the situation on 5.2?

    -act
     
  17. Trisibo

    Trisibo

    Joined:
    Nov 1, 2010
    Posts:
    245
    I also had this problem, and what I wanted was to initialize Unity Ads at runtime instead of using the new method. I have solved it just right now by enabling the ads from the services window, and then disabling it, now it works fine.
     
  18. robertwahler

    robertwahler

    Joined:
    Mar 6, 2013
    Posts:
    43
    This seems like a mess to me.

    It appears you can control initialization manually and still use the integrated 5.2 Ads code if you edit `ProjectSettings/UnityAdsSetttings.asset` manually and set `m_InitializeOnStartup: 0` There is no inspector setting for this field. This works fine on Android using the same initialization code used with the asset store Ads plugin.

    No amount of fiddling will allow us to run iOS builds with ads on 5.2 without EXC_BAD_ACCESS errors. The only way we can get an iOS build running on 5.2 is to disable Unity Ads. We had no problem with iOS on 5.1.
     
    actraiser3 likes this.
  19. biscito

    biscito

    Joined:
    Apr 3, 2013
    Posts:
    138
    i just copy and past :

    var options = newShowOptions { resultCallback = HandleShowResult};
    Advertisement.Show("rewardedVideo", options);

    and i get

    A method or delegate `canvasMain.HandleShowResultContinue(UnityEngine.Advertisements.ShowResult)' parameters do not match delegate `System.Action<UnityEngine.Advertisements.ShowResult>(UnityEngine.Advertisements.ShowResult)' parameters
     
  20. actraiser3

    actraiser3

    Joined:
    Sep 11, 2014
    Posts:
    28
    I just checked building on iOS after changing that parameter in UnityAdsSetttings.asset file and that worked for me as I can see from the Debug-Output. Unity Ads requests the correct data for the appropriate GameID I initialize at runtime. That m_InitializeOnStartup variable should be public to avoid hacking the .asset-file.

    It is not showing the ad though for some other Unity 5.2 related change or bug I assume:

    Attempt to present <UnityAdsMainViewController: 0x13d7e9520> on <UnityLandscapeLeftOnlyViewController: 0x13d56bbe0> whose view is not in the window hierarchy!

    Anyways, the basic initialization at runtime works with your hint. Thank you!

    -act
     
    Last edited: Sep 12, 2015
  21. trueDenton

    trueDenton

    Joined:
    Aug 6, 2014
    Posts:
    6
    How can I change UnityAdsSettings.asset manually ?

    I develop app for one of my client and I have his unity ad ids.

    So there is only way to use UnityAds is manual initialization.
     
  22. actraiser3

    actraiser3

    Joined:
    Sep 11, 2014
    Posts:
    28
    @trueDenton - open the file in your editor, it's just plain text
     
  23. trueDenton

    trueDenton

    Joined:
    Aug 6, 2014
    Posts:
    6
    It was a first thing i did. But it is not.
     

    Attached Files:

  24. robertwahler

    robertwahler

    Joined:
    Mar 6, 2013
    Posts:
    43
    It looks like you may need to change Edit/Project Settings/Editor Asset Serialization to "Force Text"
     
  25. mog-mog-mog

    mog-mog-mog

    Joined:
    Feb 12, 2014
    Posts:
    266
    This has broken my existing project. New services require me to login. How to disable 5.2 native UnityAds for existing projects which already have game id and unity ads integrated.

    Also for service login, What credential am I supposed to use? My developer credential or team publisher credentials used with unity ads. Does that mean every developer need to have team account access?
     
  26. mog-mog-mog

    mog-mog-mog

    Joined:
    Feb 12, 2014
    Posts:
    266
    new service does not even let me link to an existing game. it ask me for one project id, but i've two different games with unity ads for android and ios..
     
  27. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    Exact same issue, but it happened to me when I updated to 5.2.1 PATCH 4
    Dont wish to use the editor integration as the project is not fresh one but old one and lot stuff have been manually coded.
    Cannot just expect things to work automatically with this editor integration.
     
    elmar1028 likes this.
  28. elmar1028

    elmar1028

    Joined:
    Nov 21, 2013
    Posts:
    2,359
    Editor integration had to be a bit smarter. Detect if you have already a plugin installed, then simply turn itself off.
     
    MrEsquire likes this.
  29. JamesLeeNZ

    JamesLeeNZ

    Joined:
    Nov 15, 2011
    Posts:
    5,616
    You need to delete all the UnityAds SDK stuff from your project.

    I wouldnt feel comfortable with Unity Detecting I've updated then deleting a bunch of stuff.
     
  30. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    OKAY, then what? I get lot of red errors - this is missing/that is missing/you cannot do that!

    Knowing Unity buggy state as always, the issue was fixed for me when I removed the UnityAdsSDK folder, but then I re-imported UnityAds from the asset store. I'm working in offline mode and upgrading a old project, I appreciate all maybe working for fresh projects but its not always clear for existing projects.

    Apologies for the frustration
     
  31. JamesLeeNZ

    JamesLeeNZ

    Joined:
    Nov 15, 2011
    Posts:
    5,616
    Im going to assume you are using Unity 5.2.x...

    Delete all the SDK stuff, you dont need it at all. Not one file. Nada!

    Goto the Services Window/Tab. Enable Unity Ads, connect the game (make sure the id's are there). I forget if I had to set this up in the UnityAds Dashboard first (its likely)

    Include Unity.Advertisements (think that's the namespace)

    Call Advertisement.Show(null) - or whatever the function is. You dont need to Initialise. The only other code you might want to run is Advertistment.IsReady(null) before calling show.

    Thats it. If you are using a version of Unity that doesnt include UnityAds (ie prior 5.2) You're on your own sorry.
     
    MrEsquire likes this.
  32. Vurawid

    Vurawid

    Joined:
    Nov 17, 2014
    Posts:
    7
    Received this error with Unity Ads today in one of my projects. It was an easy fix in my case. Turned ON Unity Ads in the services window, then turned it back OFF.

    I prefer the Asset Store Ads package because that way preprocessor directives can be used to automatically switch to test ads when creating a development build. Also saves me from accidentally publishing a release version with test ads enabled due to forgetting to toggle that setting.
     
  33. 3CIngenious

    3CIngenious

    Joined:
    Jul 22, 2015
    Posts:
    32
    this is weird I when I turn off the unity ads the error will disappear but when I enable it again the error comesout
     
  34. Vurawid

    Vurawid

    Joined:
    Nov 17, 2014
    Posts:
    7
    I ended up having the error come back and had to take a couple extra steps. Unity is adding a reference to UnityEngine.Advertisements in the project file upon open even if UnityAds is turned off in the services window. Here is what I did to resolve it thanks to information from posts above...
    1. Edit > Project Settings > Editor
    2. Change Asset Serialization Mode to Force Text
      If it’s set to Mixed, I recommend switching to Force Binary first to avoid issues with converting to Text.​
    3. Go to the Services window
    4. Turn UnityAds On then Off
    5. Close Unity
    6. Edit the following file in Notepad or another text editor:
      <ProjectDirectory>/ProjectSettings/UnityAdsSettings.asset​
    7. Change initialize on startup to zero:
      m_InitializeOnStartup: 0​
    8. Save
    That seems to have taken care of it. The error hasn't come back again upon reopening the project or building it. Still using the UnityAds imported package.

    Edit for Clarification: These steps are for if you need to use the UnityAds package from the Asset Store. Otherwise, the package files should be removed in favor of using the integrated services version of UnityAds.
     
    Last edited: Dec 24, 2015
  35. 3CIngenious

    3CIngenious

    Joined:
    Jul 22, 2015
    Posts:
    32
    amazing will check on this when i got back home from work, thank you so much sir @Vurawid
     
  36. DevSpur

    DevSpur

    Joined:
    Jul 19, 2014
    Posts:
    20
    I found a solution that worked for me for the following errors
    error CS0433: The imported type `UnityEngine.Advertisements.Advertisement' is defined multiple times
    error CS0433: The imported type `UnityEngine.Advertisements.ShowResult' is defined multiple times
    error CS0433: The imported type `UnityEngine.Advertisements.ShowOptions' is defined multiple times
    all i did i went into the services window in unity and switched Unityads off and the errors went away and the test ad still works :):)
     
    kamran-ibadov likes this.
  37. 3CIngenious

    3CIngenious

    Joined:
    Jul 22, 2015
    Posts:
    32
    This is weird i stil have the same error,i mean it will go out then it will pop up again darn
     
  38. 3CIngenious

    3CIngenious

    Joined:
    Jul 22, 2015
    Posts:
    32
    well seems like i was not able to take out the Unity ads plugin entirely thats why I still ahve the error
     
  39. FritzH

    FritzH

    Developer Relations

    Joined:
    Aug 18, 2015
    Posts:
    45
    Hi Folks,

    The error "UnityEngine.Advertisements.method' is defined multiple times" will show up when your project includes both the old Asset package as well as the Ads service.

    The solution is to remove the Unity Ads asset package entirely; Once the Asset Package files are removed, the integrated ads service should work properly.
     
    manishdutta50 and blueinc1 like this.
  40. KarthikPabba_LaughingDots

    KarthikPabba_LaughingDots

    Joined:
    Dec 23, 2015
    Posts:
    1
    thanks bro
     
  41. Baalam

    Baalam

    Joined:
    Feb 9, 2016
    Posts:
    1
    I had both a Reference and a Plugin. I removed the Reference and it worked. Thanks!
     
  42. DBar

    DBar

    Joined:
    Jul 27, 2012
    Posts:
    71
    Hello, this update broked Space Ads demo, that i implemented a long ago in my project.
    Now, i need to debug a lot. Just to let someone know about my entire day frustration.
     
  43. rasmus-unity

    rasmus-unity

    Moderator

    Joined:
    Aug 15, 2014
    Posts:
    1,312
    @DBar, sorry to hear about that. This particular one is hard to fix in Unity, but we could improve the documentation. What steps did you take when you experienced this issue?

    -Rasmus
     
  44. DanjelRicci

    DanjelRicci

    Joined:
    Mar 8, 2010
    Posts:
    310
    I get this error every once in a while, but only when reopening Unity after a crash.
    I found an easy way to solve it. Just open any script, add a white space and save. After Unity recompiles the project, the error goes away.
     
  45. MarceloBarce

    MarceloBarce

    Joined:
    Jan 6, 2013
    Posts:
    35
    I'm stuck here and it seems to be not my fault.

    I recently upgraded my project from Unity 4.7 to 5.3 and so I removed the UnityAds plugin from my project to integrate it again from the Services window.

    The problem is, my Services/Ads windows says:
    "Unfortunately, your project cannot use the new UnityAds Dashboard yet."

    The game is still not showing up in the UnityAds Dashboard, so it seems like I'll have to stick to the old way, but how can I use the old plugin in the new 5.3?
     
  46. Alternativa

    Alternativa

    Joined:
    Jan 12, 2016
    Posts:
    1
    Thank you!
     
  47. GameTrainee

    GameTrainee

    Joined:
    May 7, 2016
    Posts:
    1
    just do simple Step Go to services then unity ads after click to advance settings and uncheck to bulitten service after unlink your project and do script for ads :)
     
  48. Deleted User

    Deleted User

    Guest

    When I added Unity Ads 2.0 from the Asset Store in Unity 5.4, I had to turn off Unity Ads in the Services window to avoid the multiple definition error. With Unity 5.5, the error is back, even though Unity Ads is still turned off in Services. Do I need to remove the Asset Store package and enable Unity Ads in Services again?
     
  49. sumitkr

    sumitkr

    Joined:
    Jun 16, 2016
    Posts:
    1
    Hey Developers I got the solution in Unity5.5 , After all cleanup and import of UnityAds2.0 go to Service--> Ads-->Advance and uncheck Enable builtin Ads extension after that all multiple definition errors cleared.
    This perfectly work for me fully tested.
     
    Nolex and goodseller like this.
  50. John_Vella

    John_Vella

    Joined:
    Nov 26, 2014
    Posts:
    114
    Does anyone know if I get this working on a game built for Android, would it still work if I copied the folder onto my Mac and made a build for iOS?

    I know I can do with with standard games, that don't have adverts, but I haven't tried it with ads yet, and was curious to see if anyone else had.