- Home /
Admob ad won't show on phone, but works in editor
Hi, I made a simple game in my free time and tried to figure out how to add more and more stuff to it. The thing I can't seem to get to work are advertisements. It works just fine in the editor, but when I build to an apk and launch the game on my phone, the ads don't work.
here is the code i used for the ads: { [SerializeField] private GameObject _transitionScreen;
string App_ID = "(this contains my app id in the code)";
//testID
string RewardedAdID = "ca-app-pub-3940256099942544/5224354917";
//echt ID
//string RewardedAdID = "(this contains my ad id in the code, but for now i use the testID above)";
private RewardedAd rewardedAd;
public void Start()
{
MobileAds.Initialize(initStatus => { });
this.rewardedAd = new RewardedAd(RewardedAdID);
// Create an empty ad request.
AdRequest request = new AdRequest.Builder().Build();
// Load the rewarded ad with the request.
this.rewardedAd.LoadAd(request);
// Called when the user should be rewarded for interacting with the ad.
this.rewardedAd.OnUserEarnedReward += HandleUserEarnedReward;
// Called when the ad is closed.
this.rewardedAd.OnAdClosed += HandleRewardedAdClosed;
}
public void HandleUserEarnedReward(object sender, Reward args)
{
PlayerStats.Fuel = 100;
PlayerStats.Health = 100;
}
public void UserChoseToWatchAd()
{
if (this.rewardedAd.IsLoaded())
{
this.rewardedAd.Show();
}
else
{
//show a screen that says an ad should be displayed but it's not working
_transitionScreen.SetActive(true);
}
}
public void HandleRewardedAdClosed(object sender, EventArgs args)
{
// Create an empty ad request.
AdRequest request = new AdRequest.Builder().Build();
// Load the rewarded ad with the request.
this.rewardedAd.LoadAd(request);
}
So, in the editor I can click on the button, I get the test ad, and I get the reward. Health and fuel are refilled
But if I run it on my phone nothing happens, no ad, no reward, not even the "transitionscreen" which is just a canvas with a textbox in it that says "there should be an ad here but it doens't seem to work".
I looked around on forums and saw similair questions pop up, but couldn't find a solution. Can anyone help me with this? (Admob account was activated over a month ago, app_ID is in the manifest, device ID of my phone was entered as a testdevice. It's probably something silly that I'm overlooking, but I can't find it...
Answer by Jojoanse · Sep 08, 2021 at 10:16 PM
Hi, I have the same problem. How did you solve it? Thanks.
I didn't... I never got a reply an haven't figured it out myself either...
Hello, the application is in the store? Have you created the ad unit for the rewarded video? I see that in the code you are using a test ad code.
Hi, I did create an ad unit, in the code, there is a line that is commented out, which contained my code for the ad. The game is no longer in the store, I kept getting messages about "inten redirection" or something, and a deadline to fix it. But I couldn't get rid of those messages either
In my case I just launch the game to the store and the ads works!
Yes that's right but we are talking about test ads they don't show up. After I tried every possible solution, I ended up learning that even test ads don' show up if your admob account's ad serving is limited, I checked that by making a new project test ads were working fine, then I changed its packagename (game A) same as a game already published test ads did not show up. And this (game A) surprised me today by showing impressions after 56k requests over one week which means the implementation is fine, even though test ads did not show up during tests. I think something is wrong from Admob's part not the implementation, just make sure your build environement is fine and test with empty project.
Answer by MarkMaa · Sep 11, 2021 at 05:19 PM
Try to add test device via: List deviceIds = new List{ "YourTestDevice From Debug Logs" }; RequestConfiguration requestConfiguration = new RequestConfiguration .Builder() .SetTestDeviceIds(deviceIds) .build();
Set up your Google Mobile Ads Settings for iOS
Check your logs when you click the AD button
And try to add Debug.Log("") as log points to check where does your code stops working. MobileAds.Initialize(initStatus => { Debug.Log("[TestAd] " + initStatus}); is recommended
Your answer
Follow this Question
Related Questions
Advert wont play 0 Answers
Adding features, eg online multiplayer android/ios 1 Answer
How to add advertisments to unity 3d games (android) 0 Answers
Mobile Ads Frameworks that support unity 0 Answers
Unity Admob glitching game screen 1 Answer