First, I've connected Admob with my Unity project following the guide https://developers.google.com/admob/unity/rewarded-video, and everything worked. It also worked after downloading from Google play. My friends tested it. Test rewarded videos were shown, real rewarded videos as well.
Then I've decided to experiment with the ads, and to add an Interstitials on level restart, following https://developers.google.com/admob/unity/interstitial
And then the problems started...
It did work with all the test ads, everything was ok
Then I've tried it with the real ads, after installing an apk directly from my device - works again. I've done the same on other phone of the family member.
Everything is fine. With both, test ads and the real ones, on both phones.
Then I've uploaded an app as a new version to Google Play, and tried it, here is what happened:
On my phone - app works, but ads don't. Now neither of them, rewarded or interstitials.
On family member's phone - app crashes right away on startup (just the one that's from play market)
On friend's phone - same thing, startup crash when downloaded from play market.
By crash I mean - black screen for a split second, nothing else, even no unity screen that says "Made in Unity"
I've tried to upload an app bundle to google play instead of apk - nothing changes.
I've tried to change my code, mostly when it is executed, when it is initialized, when called, etc - nothing helped.
Then I've tried the LogCat on a devise that had crashes.
Nothing with the word fatal or something, but I guess here is the crash:
06-05 23:20:23.969 18308 18334 E CRASH : signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 000000ba
06-05 23:20:23.969 18308 18334 E CRASH : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
06-05 23:20:23.969 18308 18334 E CRASH : Build type 'Release', Scripting Backend 'il2cpp', CPU 'armeabi-v7a'
06-05 23:20:23.969 18308 18334 E CRASH : Build fingerprint: 'motorola/athene/athene:7.0/NPJS25.93-14-18/3:user/release-keys'
06-05 23:20:23.969 18308 18334 E CRASH : Revision: 'p2a0'
And that's it, no other real info about it.
About similar questions - I saw people have lot's of problems with the same thing, including their app_id into AndroidManifest.xml - but it's not my case, it's there.
My object that holds rewarded ads is created in the menu and is not destroyed between levels. Here is some code from it:
void Awake()
{
DontDestroyOnLoad(this.gameObject);
}
void Start()
{
string appId = "my-app-id here";
MobileAds.Initialize(appId);
is_rewarded = false;
this.rewardBasedVideo = RewardBasedVideoAd.Instance;
rewardBasedVideo.OnAdRewarded += HandleRewardBasedVideoRewarded;
rewardBasedVideo.OnAdClosed += HandleRewardBasedVideoClosed;
this.RequestRewardBasedVideo();
}
public void RequestRewardBasedVideo()
{
string adUnitId = "my-rewarded-unit-id"
AdRequest request = new AdRequest.Builder().Build();
this.rewardBasedVideo.LoadAd(request, adUnitId);
}
....
My interstitial object exists only on a main level. And is destroyed when you go between levels. Here is some of my code for the interstitials:
public class InterAds : MonoBehaviour
{
public InterstitialAd interstitial;
void Start()
{
this.RequestInterstitial();
}
public void RequestInterstitial()
{
string adUnitId = "my-unit-id here";
if (this.interstitial != null)
{
this.interstitial.Destroy();
}
// Initialize an InterstitialAd.
interstitial = new InterstitialAd(adUnitId);
this.interstitial.OnAdClosed += HandleOnAdClosed;
// Create an empty ad request.
AdRequest request = new AdRequest.Builder().Build();
// Load the interstitial with the request.
this.interstitial.LoadAd(request);
}
public void HandleOnAdClosed(object sender, EventArgs args)
{
GameObject.Find("GameController").GetComponent<AudioSource>().enabled = true;
this.RequestInterstitial();
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
}
.........
I'll appreciate any help. Thanks in advance.
Upd: Now it works AND I see the ads on my device. Probably it needed time to launch them. Works on my friend's device. Still doesn't work on two other devices though.