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.

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.

Answers

  • Are you using testing account, what do people from Unity Forums say?

  • What does a testing account mean, if you mean if I kept the ad test mode checked, then yes I did keep it on.

  • Ok, are you building directly to phone (and yes, tell me is it android or iOS) or uploaded to PlayStore(or AppStore) and then downloaded on your target phone?

    And which type of ads, banner, video, rewards, or all mixed. If all, then which type are not working?

  • And are you following this guide, if not, then cross check the steps:


  • Have you registered your app on your Unity Dashboard.

  • First of all, I really appreciate your response.

    Yeah, i did build the game for android

    And i uploaded it to playstore, two days ago it went live on playstore, and there too on clicking the ad button, it says initialized but Not Ready.

    Type, it only has (Button) Reward Ads. Which ain't working

  • Yeah i did have a quick look at the documentation, infact thats where i copied the button Reward ads script from, and to me, i dont see any major step that i missed

  • sayansayan Member
    edited December 2020

    Ah, [yeah Iam new to this]

    What registration are you talking about, i mean i do have a unity ID, and my game project does show up in there along side all my other projects, there's where I got the playstore id for my game. Or do you mean something else.

  • HNJHNJ Member
    edited December 2020

    And I am talking about Unity Dashboard.

  • From: https://forum.unity.com/threads/unity-fake-ads-work-great-in-editor-but-not-on-android-or-even-published.589009/#post-4868603


    Testing

    Prior to publishing your game, enable test mode by following these steps:


    1. From the Operate tab of the Developer Dashboard, select your Project.
    2. Select Settings > Project Settings from the left navigation bar.
    3. Scroll down to the Test mode section and click the edit button on a platform(Apple App Store or Google Play Store), check Override client test mode box, then select the Force test mode ON radio button.

    In the Unity Editor, click the play button to run your Project and test your ads implementation.


    Note: You must enable test mode before testing ads integration, to avoid getting flagged for fraud.

  • Thanks again for replying this newcomer, but yeh i did what you said, Force test mode on, and just like before, it does work in pc editor, and again just like before, in android build, the ads on button click say "initialized" and "not ready", and Ivdid have my test ads checked in the service tab.

  • sayansayan Member
    edited December 2020

    And agian, I know its annoying but I still do not know what you mean be "if I have my Game registered on Unity Dashboard "


    And also on that note, suppose I do gat Ads working, and earn 6 million dollars, then how do I even receive it, coz I never gave any Money transaction related account to unity, I only game it to Playstore.

  • I also never have worked with ads in unity, but planning to do so. I just helped you with what I knew and searched the Internet.

    I think there would be a .Ready() method (less or more like that) to make them ready. I am not boldly saying, just shooting in the dark.

    And for annoying, it is OK, I also not knew what this means and that means, but I kept on reading and learning. Today also I not know perfectly some sort of things, but I will in future, and you too.

    Open the services tab in Unity Editor, and then read through this part of manual:


    And thanks for such patient.

  • Firstly, 6 Million dollars is not possible. It's a huge amount. But if suppose, you may be asked for you account number or other bank related details to transfer the amount. (don't dream of 6 Million)

  • This is Unity developer Dashboard:

    make sure your ads project is listed here, if not, add it using services tab (using the manual link above (in previous post).

  • Yeah it is listed there.

  • Then, do some research on Internet, maybe we can find something

    One thing I will suggests is asking in the ads section of Unity Forums::

    https://forum.unity.com/forums/unity-ads.67/

    People there will help you, provide all necessary details.

    I will also try to find the solution.

    Thanks.

  • HNJHNJ Member

    Is it solved?

Sign In or Register to comment.