A few days ago my ads in my game were working perfectly then suddenly out of nowhere they stopped working. I think it has something to do with unity not importing the ads extension into my game. I tried turning off the built in extension and getting the sdk from the asset store manually the errors went away but the ads would not show up. I don't know whats wrong I have everything set up my build settings is set to android and my ads are turned on I don't know why it's behaving like this

Here is my code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Advertisements;

public class Ads : Money {

  void Update()

    public void ShowRewardedAd()
        if (Advertisement.IsReady("rewardedVideo"))
            var options = new ShowOptions { resultCallback = HandleShowResult };
            Advertisement.Show("rewardedVideo", options);

    private void HandleShowResult(ShowResult result)
        switch (result)
            case ShowResult.Finished:
                money = money + 90;
                PlayerPrefs.GetInt("money", money);
                PlayerPrefs.SetInt("money", money);
                Debug.Log("The ad was successfully shown.");
            case ShowResult.Skipped:
                Debug.Log("The ad was skipped before reaching the end.");
            case ShowResult.Failed:
                Debug.LogError("The ad failed to be shown.");

As you can see I basically copied this from the unity code samples section and modified it a little to fit my needs.

Here are the errors:

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

Assets/Ads.cs(24,35): error CS0246: The type or namespace name `ShowResult' could not be found. Are you missing an assembly reference?

  • \$\begingroup\$ Check your build settings for Android or iOS and toggle the Enable Ads extension. answers.unity3d.com/questions/1294598/… \$\endgroup\$ – lyinch May 24 '17 at 12:17
  • \$\begingroup\$ After I put the unity ads sdk into my project i deleted it and checked the Built in ads extension box. My build setting are set to android and I still have the same problem \$\endgroup\$ – Jayson Meribe May 24 '17 at 19:30
  • \$\begingroup\$ Hlw....Can you please let me know how you solved the problem? Thanks in advance. \$\endgroup\$ – Md. Assaduzzaman Niloy Nov 17 '17 at 22:48

Let's take a look at the first error message:

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

The compiler is saying that it can't find UnityEngine.Advertisements. This means you don't have ads enabled. To enable ads, as of Unity 5.2, you should use the Unity Service Window and not the Asset Store package. Before you can use Unity Services, you need to get a Unity Services Project ID.

From the Unity documentation for Unity Services:

To get started with Unity’s family of services, you must first link your project to a Unity Services Project ID.


Go to Window > Unity Services, or click the cloud button in the toolbar.


Select your organization and click Create.

Your project now has a special ID it can use to talk to Unity servers and ask for advertisements. Now you can enable Unity Ads. From the documentation for Unity Ads:

  1. Open the Ads configuration window from Window > Services > Ads.

  2. Click the switch on the right-hand side to turn Ads on, then answer a few questions about the game you are making.

At this point, the compiler should stop showing errors, and your code should run just fine.

  • \$\begingroup\$ Sorry, I already fixed this problem thanks for the help though \$\endgroup\$ – Jayson Meribe Jun 1 '17 at 22:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.