Search Unity

Unity ads missing assembly reference?

Discussion in 'Unity Ads' started by Sunray98, Jan 11, 2017.

  1. Sunray98

    Sunray98

    Joined:
    Jan 1, 2017
    Posts:
    10
    Hey I'm trying to get unity ads to work in my new project I'm getting:

    Assets/Game.cs(5,19): error CS0234: The type or namespace name `Advertisements' does not exist in the namespace `UnityEngine'. Are you missing an assembly reference?

    I have ads enabled and the build in extension it worked fine in my last project.
     
  2. rasmus-unity

    rasmus-unity

    Unity Technologies

    Joined:
    Aug 15, 2014
    Posts:
    1,177
  3. Sunray98

    Sunray98

    Joined:
    Jan 1, 2017
    Posts:
    10
  4. rasmus-unity

    rasmus-unity

    Unity Technologies

    Joined:
    Aug 15, 2014
    Posts:
    1,177
    No problem. You are not the first to encounter this, so might be we can improve at least the error message.

    /Rasmus
     
  5. Sievlar

    Sievlar

    Joined:
    Oct 3, 2012
    Posts:
    60
    UNITY_ADS was not needed when using the Asset Store version of Unity Ads, why the change?
     
  6. rasmus-unity

    rasmus-unity

    Unity Technologies

    Joined:
    Aug 15, 2014
    Posts:
    1,177
    UNITY_ADS is for convenience (at least that was the intention). With Ads SDK package from asset store, you would still need to use e.g. UNITY_IPHONE and/or UNITY_ANDROID conditionals in your code, if shipping for other platforms.

    Hope it answers your question.

    /Rasmus
     
  7. Sievlar

    Sievlar

    Joined:
    Oct 3, 2012
    Posts:
    60
    With the Asset Store version I was able to build for Windows UWP without the need for UNITY_ADS, or UNITY_IPHONE, etc. Which made my code much cleaner. Now I had to refactor my code with a bunch of ugly #if UNITY_ADS after switching to the internal version.
     
  8. rasmus-unity

    rasmus-unity

    Unity Technologies

    Joined:
    Aug 15, 2014
    Posts:
    1,177
    Ok, you are right. However the reason for this has been concerns about binary sizes, for which reason Ads SDK is only included in builds for Android and iOS.

    Remember you can still use the Ads SDK from asset store if you like. Although sounds like you have refactored your code now anyways.

    /Rasmus
     
  9. Sievlar

    Sievlar

    Joined:
    Oct 3, 2012
    Posts:
    60
    Unfortunately I had to switch back to the Asset Store version anyway, the internal one does not work with published apps on iOS.
     
  10. rasmus-unity

    rasmus-unity

    Unity Technologies

    Joined:
    Aug 15, 2014
    Posts:
    1,177
    Did you experience this yourself, or is it based on other reports on the forum? We have shipped own games with the integrated Ads SDK to TestFlight and haven't experienced the mentioned problems.

    /Rasmus
     
  11. Sievlar

    Sievlar

    Joined:
    Oct 3, 2012
    Posts:
    60
    Yes, everything was working locally, however via TestFlight it did not work. After reverting to Asset Store version it worked via TestFlight.
     
  12. rasmus-unity

    rasmus-unity

    Unity Technologies

    Joined:
    Aug 15, 2014
    Posts:
    1,177
    Does that mean that it worked in the editor, i.e. you got the "Here would be your ad" placeholder? How about when you deploy to local device for testing?

    /Rasmus
     
  13. Sievlar

    Sievlar

    Joined:
    Oct 3, 2012
    Posts:
    60
    It worked in the editor and locally on my device when deployed from Xcode.
     
  14. rasmus-unity

    rasmus-unity

    Unity Technologies

    Joined:
    Aug 15, 2014
    Posts:
    1,177
    Hmm, so worked locally from Xcode but not in TestFlight? Do you still have the TestFlight version available?
     
  15. Sievlar

    Sievlar

    Joined:
    Oct 3, 2012
    Posts:
    60
    I had replaced it, however I just went back to the internal Unity Ads and pushed a new build using TestMode to the iOS TestFlight. It once again repros the issue. I.e. Unity Ads is initialized, but none are available.

    I just created a Beta App Review request and added unityads-support@unity3d.com as a tester. Hopefully it gets approved.
     
  16. Sievlar

    Sievlar

    Joined:
    Oct 3, 2012
    Posts:
    60
    Beta App was approved and notification sent to the above email.
     
  17. robdil

    robdil

    Joined:
    Nov 12, 2013
    Posts:
    6
    I am having the same issue as the original poster: my game was actually working perfectly in 5.5.0, with ads being called as expected, and then out of nowhere I got the "Advertisements namespace does not exist" error.

    I was using UNITY_ANDROID in my scripts and after checking this thread I modified them with UNITY_ADS instead. Anyway, all code within is actually greyed (with Android target platform selected for the build, of course) and it is not called at all when the game runs on my phone. It is like the #if directive isn't recognised at all.
    I just upgraded to 5.5.1 (on Win 10) and no difference.
    Any suggestion?

    Thanks!!

    EDIT: found the issue: somehow the "Enable builtin ads extension" in the advanced settings got unchecked!
     
    Last edited: Jan 31, 2017
  18. Sievlar

    Sievlar

    Joined:
    Oct 3, 2012
    Posts:
    60