Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Unity (test)Ads works in Editor, but not in Android Build. Help

Hello there, Its my first time attempting to implement Ads to a game. I have the Rewarded Ads option that appears on players fifth death. In editor, the sample Ad shows perfectly. But when I build it for android and try it there, on clicking the ads button, it does nothing. (also I am not sure if this question should be asked in the programming forum of brackeys, I did it here anyway)

I put texts in each case which would appear on screen, and from there I realized that in android it does initialize but goes no farther.

Here is my Ads Script




using UnityEngine;

using UnityEngine.Advertisements;

using UnityEngine.UI;




public class NewBehaviourScript : MonoBehaviour, IUnityAdsListener

{



  private string gameId = "12345679";

  private string gameAid = "12345678";


 // Button myButton;

  public string myPlacementId = "rewardedVideo";


public bool isTargetAppStore;

public bool isTestAD;


public Text CountTextt;

 

public GameObject myObject;

public GameObject myObject2;

public GameObject myObject3;

public GameObject myObject4;

public GameObject myObject5;

     


  // Start is called before the first frame update

  void Start() 

{

 Advertisement.AddListener (this);

InitializeAdvertisement(); 

if (!Advertisement.isInitialized)

{

CountTextt.text = "....";

Advertisement.Initialize(gameId, isTestAD);

}

else {

CountTextt.text = "..";}

    myObject.SetActive(false); 

 myObject2.SetActive(false); 

 myObject3.SetActive(false);  

 myObject4.SetActive(false); 

 myObject5.SetActive(false); 

    

}

  

    private void InitializeAdvertisement()

 { 

 if(isTargetAppStore) 

{Advertisement.Initialize(gameId, isTestAD); 

//return;

}

//Advertisement.Initialize(gameId, isTestAD);

  }


  public void PlayRewardedVideo() {

   if(!Advertisement.IsReady(myPlacementId)) 

{

CountTextt.text = "not ready";

return; 

}

 if(Advertisement.IsReady(myPlacementId)) {

CountTextt.text = "ready";

Advertisement.Show(myPlacementId);

}  }


 public void OnUnityAdsReady (string placementId) {

     

  }


  public void OnUnityAdsDidFinish (string placementId, ShowResult showResult) {

    // Define conditional logic for each ad completion status:

    if (showResult == ShowResult.Finished) {

      // Reward the user for watching the ad to completion.

CountTextt.text = "Finished";


if ( myObject != null) {

      myObject.SetActive(true);}


else if ( myObject2 != null) {

      myObject.SetActive(true);}

else if ( myObject3 != null) {

      myObject.SetActive(true);}

else if ( myObject4 != null) {

      myObject.SetActive(true);}

else if ( myObject5 != null) {

      myObject.SetActive(true);}

 


}     

 else if (showResult == ShowResult.Skipped) {

      Debug.Log("skipped");

CountTextt.text = "skipped";

    } else if (showResult == ShowResult.Failed) {

      // Debug.LogWarning (“The ad did not finish due to an error.”);

Debug.Log("Failed");

CountTextt.text = "failed";

    }

  }


  public void OnUnityAdsDidError (string message) {

    Debug.Log("Error");

CountTextt.text = "Error";

  }


  public void OnUnityAdsDidStart (string placementId) {

    // Optional actions to take when the end-users triggers an ad.

Debug.Log("Started");

//CountTextt.text = "Started";


  } 

}



Few more details

in editor, the first time I come across the ad bottun, it shows this text '....'

after that one time, all the other times it only shows '..'

, until I quit play mode.

and ofc in android it stays "...." and on clicking I does nothing, and just remains to show this text "...."



Any response will be appreciated, thankyou.

Sign In or Register to comment.