Android Question The ad unit ID must be set on InterstitialAd before show is called.

D

Deleted member 103

Guest
Hi,

this message comes from Crashlytics Report.
How can it happen?


B4X:
Sub Activity_Create(FirstTime As Boolean)
...
    'Werbung initialisieren
    If Not(Starter.IsProVersion) Then
        'Admob-Interstitial
        AdView1.Initialize("AdView1","ca-app-pub-xxxxxxxxxxxxxxxxxxxxxxxxxxxx")
        LoadAd
    End If
...
End Sub

Sub LoadAd
    'Log("LoadAd")
    Dim builder As AdRequestBuilder
    builder.Initialize
    Dim consent As ConsentManager = Starter.consent
    If consent.IsRequestLocationInEeaOrUnknown Then
        If consent.ConsentState = consent.STATE_NON_PERSONALIZED Then
            builder.NonPersonalizedAds
        Else if consent.ConsentState = consent.STATE_UNKNOWN Then
            Return
        End If
    End If
#if not(Release)
    builder.AddTestDevice("xxxxxxxxxxxxxxxx") 'Samsung A5(2017)
#End If
    AdView1.LoadAdWithBuilder(builder)
End Sub

Sub AdView1_ReceiveAd
    'Log("AdView1_ReceiveAd")
    AdView1.Show
End Sub
 
D

Deleted member 103

Guest
Does it work if you call LoadAd?
Yes, without problems! As always, however, I can not reproduce the error with my test devices.

Are you sure that AdView type is InterstitialAd?
Yes


The error is currently on the following devices:
Gerät
Marke: samsung
Modell: Galaxy J3(2016)
Ausrichtung: Hochformat
Freier RAM: 263.07 MB
Freier Festplattenspeicher: 400.06 MB

Betriebssystem
Version: 5.1.1
Ausrichtung: Hochformat
Rooting durchgeführt: Nein

Gerät
Marke: samsung
Modell: Galaxy Grand Prime
Ausrichtung: Hochformat
Freier RAM: 299.65 MB
Freier Festplattenspeicher: 1.83 GB

Betriebssystem
Version: 5.0.2
Ausrichtung: Hochformat
Rooting durchgeführt: Nein

Gerät
Marke: samsung
Modell: Galaxy S7 Edge
Ausrichtung: Hochformat
Freier RAM: 1.49 GB
Freier Festplattenspeicher: 7.88 GB

Betriebssystem
Version: 8.0.0
Ausrichtung: Hochformat
Rooting durchgeführt: Nein
 
Upvote 0
D

Deleted member 103

Guest
Are you calling LoadAd multiple times?
I call "LoadAd" in 3 different Activity each in "Activity_Create" 1 times.

Make some tests and kill the activity and recreate it while the ad is loaded.
Thanks, I have to try that.
 
Upvote 0

Computersmith64

Well-Known Member
Licensed User
Longtime User
Maybe also try using AdView1.Ready before you call AdView1.Show. Maybe there's a slight delay between when ReceiveAd is fired & it's actually ready.

If you're using Firebase Analytics you could log true & false results from AdView1.Ready - that way you can confirm (or not) if sometimes the ad isn't actually ready when ReceiveAd is fired.

- Colin.
 
Upvote 0
D

Deleted member 103

Guest
Thanks for the tip, it looks better now.

B4X:
Sub AdView1_ReceiveAd
    'Log("AdView1_ReceiveAd")
    If AdView1.Ready Then AdView1.Show
End Sub
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…