Coding Gents
Coding Gents

Reputation: 1

Unity AdMob[Google Ads] doesn't show anything

It seems that I can't find any reason the advertising should not work.

But it didn't work.

I event followed some YouTube tutorial with some Eclipse compiling of an Jar file, but still not working.

Here is the code:

    using UnityEngine;
    using System.Collections;
    using GoogleMobileAds.Api;

    public class mainMenuCamera : MonoBehaviour {
    // Use this for initialization
    void Awake()
    {
        RequestBanner ();
    }
    void Start () {

    }

    // Update is called once per frame
    void Update () {

    }

    private void RequestBanner()
    {
        #if UNITY_EDITOR
        string adUnitId = "unused";
        #elif UNITY_ANDROID
        string adUnitId = " ";
        #else
        string adUnitId = "unexpected_platform";
        #endif

        BannerView bannerView = new BannerView (adUnitId, AdSize.Banner, AdPosition.Top);
        AdRequest request = new AdRequest.Builder()
            .AddTestDevice(AdRequest.TestDeviceSimulator)       // Simulator.
                .AddTestDevice("0123456789ABCDEF0123456789ABCDEF")  // Test Device 1.
                .Build();
        bannerView.LoadAd (request);

    }
}

Upvotes: 0

Views: 5204

Answers (2)

unitygamer1990
unitygamer1990

Reputation: 11

Downloads Admob Unity Plugin

AdmobPluginRes/GoogleMobileAds.framework and admob_unity_plugin.unitypackage is reqired Download those files from Admob Unity3d Plugin Project Home https://github.com/unity-plugins/Unity-Admob or Download all the Unity admob plugin project https://github.com/unity-plugins/Unity-Admob/archive/master.zip

Installation Admob Unity

Open your project in the Unity editor. Navigate to Assets -> Import Package -> Custom Package. Select the AdmobUnityPlugin.unitypackage file. Import all of the files for the plugins by selecting Import. Make sure to check for any conflicts with files.

Init Admob Unity Plugin

Create A C# script ,drag the script to a object on scene , add the follow code in the script file

  using admob;
    Admob.Instance().initAdmob("admob banner id", "admob interstitial id");//admob id with format ca-app-pub-279xxxxxxxx/xxxxxxxx
    //Admob.Instance().initAdmob("ca-app-pub-3940256099942544/2934735716", "ca-app-pub-3940256099942544/4411468910");

Here is the minimal code to create an interstitial.

Admob.Instance().loadInterstitial(); 

interstitials need to be explicitly shown. At an appropriate stopping point in your app, check that the interstitail is ready before showing it:

 if (Admob.Instance().isInterstitialReady()) {
      Admob.Instance().showInterstitial();
    }

This is what I followed ,and show Interstitial success,but I get error when show reward video.so chapfallen.

Upvotes: 1

bahaha
bahaha

Reputation: 1

Try creating an Admob account and putting in the AdUnit ID. Also, make sure that the Main Camera (whatever layer you attached it to) is the top layer. In my game, the Main Camera was set in the middle of other layers and would not show anything until I moved it to the top

Upvotes: 0

Related Questions