Unity Ads not showing on Android device

I have a Script with this line:

Advertisement.Initialize("MyGameCode",true);

Also I created a button with this script:

using UnityEngine;
using System.Collections;
using UnityEngine.Advertisements;
public class AdTest : MonoBehaviour {

    public dfButton AdShow;
    public string zone;
    public bool isReady;

    void Update(){
        isReady = Advertisement.isReady(zone);
        AdShow.Text = isReady ? "Show Ad" : "Waiting...";
        AdShow.IsInteractive = isReady;
    }
public void ClickShowAd(){
        if (isReady){
            Advertisement.Show(zone);
    }
    }
    }

Test Ads appear on Editor:


When I click the button…It works.

But on device it’s not loading.
Only waiting…

I’m also using this asset so I don’t know if it’s related to it or…

And here is my manifest:

onemoreuser091 hello,

Could you pls try using Advertisement.isReady(zone); out of update() function.

thank you,

Well…my first try was with this one:
https://gist.github.com/wcoastsands/3d003528a76f94fa2ede
Which I found in this thread:
http://forum.unity3d.com/threads/ads-dont-display-on-android.270920/
But I don’t have a gameobject called UnityAds.
I tried on an empty project in it seems to work so I don’t know what wrong.Maybe it’s because of android native plugin. I thought my manifest was correct.
I also saw that unity ads comes with a “device.jar” file and the other plugin has the “android native.jar” one.

In your AdTest script, how are you setting the value for isReady? Like Salazar suggested, you should be using Advertisement.isReady(zone), which you could use with isReady as a property, like so:

public bool isReady { get { return Advertisement.isReady(zone); }}

Also, if you can post a link to the logcat output, it should provide clues to what’s happening.

It’s not a problem of the code because it works on editor and in the device too when I build it from other empty project.
I saw some AndroidJava exception with class AndroidNativeBridge so I think it’s related to the android native plugin but I don’t know how to fix this.Anyway I’m not sure if this the problem…

1850436–118676–logcat.txt (456 KB)

So I changed the manifest from this:

<activity android:name="com.androidnative.AndroidNativeBridge" android:label="@string/app_name" android:screenOrientation="sensorLandscape" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:launchMode="singleTask">
      <meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="true" />
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
    </activity>

        <activity
              android:name="com.unity3d.ads.android.view.UnityAdsFullscreenActivity"
              android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen"
              android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
              android:hardwareAccelerated="true" />
    </application>

To this one:

    <activity
android:name="com.unity3d.player.UnityPlayerActivity" android:label="@string/app_name" android:screenOrientation="sensorLandscape" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:launchMode="singleTask">
      <meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="true" />
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
    </activity>


        <activity
              android:name="com.unity3d.ads.android.view.UnityAdsFullscreenActivity"
              android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen"
              android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
              android:hardwareAccelerated="true" />
    </application>

Unity Ads needs unity 3d activity to be the main? Now Test ads appear but I can’t close them so I’m a bit closer…anyway I still don’t know what the correct way to have them both working.

Edit: I don’t know if I implemented correctly or not but at least video ad seems to work now. I still can’t close the picture ad.

Did you only change the name parameter of the activity tag?

Not seeing anything obvious from the logcat you posted. Would you mind exporting your project as an asset package and sending me a link to it in a private conversation?

Thanks

Also, not clear on where the manifest you’re using came from, or if it’s valid.

Unity Ads 1.0.4 (SDK 1.3.9) has it’s manifest stored under Plugins/Android/unityads.

The contents of which are as follows:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.unity3d.ads.android"
    android:versionCode="1"
    android:versionName="1.0" >

    <application>
        <activity
              android:name="com.unity3d.ads.android.view.UnityAdsFullscreenActivity"
              android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen"
              android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
              android:hardwareAccelerated="true" />
    </application>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
</manifest>

The manifest I have is a merged version of Android Native plugin and Unity Ads.
And yes, if I tag the NativeBridge and filter as main and launcher then unity ads won’t work.
Also setting unityplayer as main still has some bugs like blackscreen with pictureads.
But I need this plugin to be main activity or the other features(billing,social,etc…) won’t work.

My current project is too big in size and is too messy so I will send a package reproducing the problem I have, with only Unity ads and this plugin.

I thought to remove the other plugin at the moment because I’m not using any important feature. But now even empty project with only unity ads imported,has stopped working.
When I touch the show ad button to show a test picture ad, screen just goes grey like it tries to launch but never launches…
I tried to download the unity ads package again but same problem.
So now:
-Unity ads+Native plugin: Unity ads never Initialize.
-Unity ads only: Unity ads Initialize,find ads but picture ads never launch and only stay at the grey screen

I sent a link to the package a while ago… It’s not working? You didn’t had time to test?
How can I fix this?What I’m doing wrong? Or at least how to get picture ads working.Please help.

I got the package, thank you. Just haven’t had the chance to test yet. Will get a chance to do so today.

Keep in mind picture ads are still in beta. There may not be any campaigns running for your region. Be sure to initialize Unity Ads with testMode enabled to make sure you can at least see test ads.

I’ll follow up with you again here soon after I’ve had a chance to test the package. Thanks for pinging me on this.

I am having a very similar problem to the one originally posted here. I can run my ad script in the editor and it will tell me that everything is working ok but when I build the game it will endlessly tell me that it is “Waiting…”. I have also tried using an example project and building that to my tablet and that also does the exact same thing.

All I could do for now is to disable picture ads when no more videos are available in the Unity Ads placement settings. Although this is not a solution. I understand that this picture ads still in beta so no picture ads are available to show. But the problem is when I use this script button (Waiting …) If the button works, and appears (SHOW AD). Then what happens is that the screen turns grey, like when an app is started. But, no ad was shown and I can not return to the game.

Make sure that if the zone value is empty, that it gets set to null before being passed. When a null value is set, Unity Ads uses the default ad placement zone. The same is not true when an empty string is set.

if (string.IsNullOrEmpty(zone)) zone = null;

I’ve recently updated the demo project. Might be worth looking through the revised helper and example scripts. See the commit logs for change notes. Let me know if you have any questions.

I am having the same problem. UnityAds and Everyplay does not work if I change the main activity on AndroidManifest. I am using AndroidNative plugin which overrides the main activity, please let me know how did you solve this?

FIXED!

After fiddling around a lot I found the solution.

In Unity Ads > click on your game > Click on your game store listing (eg the tab that has your game ID in >
Click on settings next to ad filtering > And turn "Override client test mode OFF!

2 Likes

I am having the same problem. The test ads show in the editor but not in the game build. turning “Override client test mode - OFF” doesn’t fix the problem either.

I am using the following code for my game. It used to work for iOS. but now i am having issue on running on my Android Device (It worked before I added the “package_name” on “store_id” under the “Organization” → “Game” → “Google Play”).

Looking forward to hear some solution.
@unity-nikkolai

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

public class AdsReward : MonoBehaviour {

    public static AdsReward instance;

    [Header("Ads Settings")]
    public bool enableTestMode;

    #if UNITY_ANDROID

    private string gameID = "XXXXXXX";

    #elif UNITY_IOS

    private string gameID = "XXXXXXX";

    #endif

    void Awake(){


        if (instance == null) {

            instance = this;
            StartCoroutine (InitializedAds ());
        } else if (instance != this)
            Destroy (gameObject);

        DontDestroyOnLoad (gameObject);


    }

    void Start(){

        //instance = this;

        //StartCoroutine (InitializedAds ());
    }

    private IEnumerator InitializedAds(){

        if (Advertisement.isSupported) {

            Advertisement.Initialize (gameID, enableTestMode);
        }


        while (!Advertisement.isInitialized || !Advertisement.IsReady ()) {

            yield return new WaitForSeconds (0.5f);
        }
    }


    public void ShowAds(){

        if (Advertisement.IsReady ("rewardedVideo")) {

            Advertisement.Show ("rewardedVideo", new ShowOptions () {

                resultCallback = HandleRewardAdResult
            });
        }else if(Advertisement.IsReady("video")){

            Advertisement.Show ("video", new ShowOptions () {

                resultCallback = HandleVideoAdResult
            });
        }
    }

    //-----------------------------------------------------------------------------

    public void ShowRewardVideoAds(){

        if (Advertisement.IsReady ("rewardedVideo")) {

            Advertisement.Show ("rewardedVideo", new ShowOptions () {

                resultCallback = HandleRewardAdResult
            });
        }
    }

    private void HandleRewardAdResult(ShowResult result){

        switch (result) {

        case ShowResult.Failed:
            //Debug.Log ("Failed To Load The RewardAds");
            break;
        case ShowResult.Skipped:
            //Debug.Log ("Skip RewardAds");
            break;
        case ShowResult.Finished:
            //Debug.Log ("Finished RewardAds");
            //GAGameAnalyist.ourGAGameAnalysit.TrackRewardedAds ();
            break;
        }
    }

    //-----------------------------------------------------------------------------

    public void ShowVideoAds(){

        if(Advertisement.IsReady("video")){

            Advertisement.Show ("video", new ShowOptions () {

                resultCallback = HandleVideoAdResult
            });
        }
    }

    private void HandleVideoAdResult(ShowResult result){

        switch (result) {

        case ShowResult.Failed:
            //Debug.Log ("Failed To Load The VideoAds");
            break;
        case ShowResult.Skipped:
            //Debug.Log ("Skip VideoAds");
            break;
        case ShowResult.Finished:
            //Debug.Log ("Finished VideoAds");
            //GAGameAnalyist.ourGAGameAnalysit.TrackVideoAds ();

            break;
        }
    }
}

Same problem here. Works in Unity editor, but the version that’s in the android play store doesn’t show the advert.
I’m a bit of a newby, but I can’t see why it should work in testing, then not on the target device.

using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
using UnityEngine.Advertisements;
public class Advertising : MonoBehaviour {
//---------- ONLY NECESSARY FOR ASSET PACKAGE INTEGRATION: ----------//
#if UNITY_IOS
private string gameId = "2680606";
#elif UNITY_ANDROID
private string gameId = "2680604";
#else
private string gameId = "";
#endif
//-------------------------------------------------------------------//
private string placementID;
private ShowOptions options;
private bool showOn = true;
void Start () 
{
Advertisement.Initialize(gameId);
ShowVideo("rewardedVideo");
}
void Update () {
// Debug.Log ("Advertisement Is Ready " + Advertisement.IsReady (placementID));
if (Advertisement.IsReady (placementID) && showOn) {
Advertisement.Show (placementID, options);
showOn = false;
}
}
void ShowVideo (string pID)
{
placementID = pID;
// Debug.Log("Unity Ads initialized: " + Advertisement.isInitialized);
// Debug.Log("Unity Ads is supported: " + Advertisement.isSupported);
// Debug.Log("Unity Ads test mode enabled: " + Advertisement.testMode);
//StartCoroutine();
options = new ShowOptions();
options.resultCallback = HandleShowResult;
}
void HandleShowResult (ShowResult result)
{
if(result == ShowResult.Finished) {
//Debug.Log("Video completed - Offer a reward to the player");
// Reward your player here.
PlayerStatic.gold = PlayerStatic.gold + 50* PlayerStatic.level;
//Debug.Log ("Player got: " + 50 * PlayerStatic.level);
//Debug.Log (PlayerStatic.gold);
PlayerStatic.Save ();
}else if(result == ShowResult.Skipped) {
//Debug.LogWarning("Video was skipped - Do NOT reward the player");
}else if(result == ShowResult.Failed) {
//Debug.LogError("Video failed to show");
}
if (result == ShowResult.Finished || result == ShowResult.Skipped || result == ShowResult.Failed) {
SceneManager.LoadScene("GameShop");
}
}
}