So basically I am another one of these people stuck with making Google Admob work properly on their app.
I am implementing rewarded ads and testing with test ads (or at least trying to, before I start considering production code).The code works fine in the unity editor and I manage to get the fake ads that are shipped within the Admob package displayed and progress the code to the point to reward users for watching those ads.
WHAT I TRIED:
1.Following the AdMob documentation for integration on my main app
2. Fresh project with bare minimum also following documentation
3. I use various AI helpers to code and debug my code, but even AI seems stuck on this giving me some half baked answers
4. Searched the web, stack exchanges, forums, you name it (almost a week of struggles)
5. Logging the ad-displaying code progress points into a text field on the app to get more info where I am failing and I drilled it to the RewardedAd.Load function either not firing or failing without any logs to help me figure out what I am doing wrong/missing.
MY SUSPICIONS:
1. Either something is broken within the AdMob package (possible, but unlikely as I see people on you tube happily showing off how to do it and working for them, but none of what people suggest or explain really helps me because I did what they show or they aren't showing something "obvious" that I may be missing)
2. The SDK not being properly integrated so that the RewardedAd.Load fires properly --> this one is more likely a reason, but I have no idea where I could be wrong on this one as I followed the integration part from the AdMob for unity documentation. Since it works in the unity editor, I am thinking that the gradle files or manifests might be missing some important data which still lets the apk get built, but doesn't allow the function to fire properly in the app.
As mentioned, I get no logs from the RewardedAd.Load function while using the app, so it's hard to figure out if I am missing some manifest file or gradle file code to make the built app code work or am I just dumb to not see the obvious.
Here is the LoadRewardedAd function with what I tried when debugging the problems on the actual app not the editor, because as said, in the editor works fine. Also to be more explicit on why I believe I drilled it to the RewardedAd.Load function not working properly is that the log above the function gets logged and the one below it doesn't, which simply means something goes wrong there and code breaks not logging what is after it.
public void LoadRewardedAd()
{
if (!IsInternetAvailable())
{
Debug.LogError("No internet connection.");
debugLogText.text += "No internet connection.\n\n";
return;
}
if (rewardedAd != null)
{
rewardedAd.Destroy();
rewardedAd = null;
}
Debug.Log("Loading the rewarded ad.");
debugLogText.text = "Loading the rewarded ad. \n\n";
RewardedAd.Load(rewardedAdUnitId, new AdRequest(),
(RewardedAd ad, LoadAdError error) =>
{
if (error != null || ad == null)
{
Debug.LogError("Rewarded ad failed to load: " + error.GetMessage());
debugLogText.text += "Rewarded ad failed to load: " + error.GetMessage() + "\n\n";
return;
}
Debug.Log("Rewarded ad loaded with response: " + ad.GetResponseInfo());
debugLogText.text += "Rewarded ad loaded with response: " + ad.GetResponseInfo() + "\n\n";
rewardedAd = ad;
RegisterEventHandlers(rewardedAd);
});
debugLogText.text = "This won't happen if the AD LOADING breaks. \n\n";
}
Hopefully there is someone with more experience who will see the obvious I am not seeing and help me drill this down. Also if you need more parts of the code or contents in the manifest and gradle files ask away, if it helps you drill to the possible problem. I didn't want to spam the post with too much code and files as I have no idea which files could be poorly edited and in which specific locations of the project, so just wanted to try and explain my issue for starters and go from there if anyone can make sense from what I posted and is able to help.
THX IN ADVANCE FOR YOUR TIME