B4X:
Sub iadpremium_FailedToReceiveAd (ErrorCode As String)
LogColor("PREMIUM Error Code: "&ErrorCode,Colors.green)
if builder.isinitialized=false then builder.initialize
iad.LoadAdWithBuilder(builder)
End Sub
I have an increasing rate of crashes about this error after an update I made. I am using the latestadmob with consent. ( what I changed related to this is , I had loadad call in actiivty_create and activity resume, I moved it to activity _resume only because it was loading 2 times)
I have the loadad call under actibity_resume so that it is called once when the application first starts. I have the builder.initialize in globals not in this sub as in the Erel's example:
B4X:
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
' builder.AddTestDevice("1BF76F3B1F0A7BCAA2FE57E91364BE63")
If uyelik=False Then
bannerpremium.LoadAdWithBuilder(builder)
iadpremium.LoadAdWithBuilder(builder)
Else
End If
End Sub
because outside this sub I also load ads with builder ( if one interstitial ad unit fails i load another adunit for interstitial with lower ecpm)
B4X:
Sub iadpremium_FailedToReceiveAd (ErrorCode As String)
LogColor("PREMIUM Error Code: "&ErrorCode,Colors.green)
iad.LoadAdWithBuilder(builder)
End Sub
this is where error happens it says
Object should first be initialized (AdRequestBuilder).
I cant produce this error , it shows in crashlytics for many users. I don't understand how adrequestbuilder is not initialized, because to iadpremium_failedtoreceivead to fire, we need to have called loadad and if we have called the loadad we have builder.initialize on the first line.
Anyone has an idea ?
full error report under crashlytics :
B4X:
Fatal Exception: java.lang.RuntimeException: Object should first be initialized (AdRequestBuilder).
at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:50)
at anywheresoftware.b4a.admobwrapper.AdViewWrapper$InterstitialAdWrapper.LoadAdWithBuilder(AdViewWrapper.java:328)
at ct.canlidoviz.main._iadpremium_failedtoreceivead(main.java:2726)
at java.lang.reflect.Method.invoke(Method.java)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
at anywheresoftware.b4a.BA$2.run(BA.java:370)
at anywheresoftware.b4a.BA.setActivityPaused(BA.java:442)
at ct.canlidoviz.main.afterFirstLayout(main.java:108)
at ct.canlidoviz.main.access$000(main.java:17)
at ct.canlidoviz.main$WaitForLayout.run(main.java:82)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6944)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
edit:
I could create the error now on my device. Just after I launch the app , if i close it there are printed on the logs :
sending message to waiting queue (iadpremium_failedtoreceivead)
so Just after I resume the app first this sub is called bbecause it is in the queue and error happens. So If I change the iadpremium_failedtoreceivead sub like this :
should it be ok ?
Last edited: