Android Question GooglePlay Console Fails

Ederson Kerber

Member
Licensed User
Hi,

I'm getting the below crash in an app on GooglePLay Console:

java.lang.NullPointerException: at com.google.android.gms.common.internal.Preconditions.checkNotNull(com.google.android.gms:play-services-basement@@17.6.0:2)
at com.google.android.gms.ads.interstitial.InterstitialAd.load(com.google.android.gms:play-services-ads-lite@@20.1.0:2)
at anywheresoftware.b4a.admobwrapper.AdViewWrapper$InterstitialAdWrapper.LoadAdWithBuilder (AdViewWrapper.java:198)
at anywheresoftware.b4a.admobwrapper.AdViewWrapper$InterstitialAdWrapper.LoadAd (AdViewWrapper.java:191)
at com.cartaodecreditoguia.mlt.main._iad_adclosed (main.java:1135)
at java.lang.reflect.Method.invoke (Native Method)
at anywheresoftware.b4a.BA.raiseEvent2 (BA.java:213)
at anywheresoftware.b4a.BA$2.run (BA.java:387)
at anywheresoftware.b4a.BA.setActivityPaused (BA.java:459)
at com.cartaodecreditoguia.mlt.main.afterFirstLayout (main.java:109)
at com.cartaodecreditoguia.mlt.main.access$000 (main.java:17)
at com.cartaodecreditoguia.mlt.main$WaitForLayout.run (main.java:83)
at android.os.Handler.handleCallback (Handler.java:873)
at android.os.Handler.dispatchMessage (Handler.java:99)
at android.os.Looper.loop (Looper.java:214)
at android.app.ActivityThread.main (ActivityThread.java:7078)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:494)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:964)

I'm using FirebaseAdMob2 as shown in the link:
https://www.b4x.com/android/forum/threads/firebaseadmob2-google-mobile-ads-sdk-v20.129609/#content.
All items recommended in SDK Manager are installed. B4A Version 10.70.

Manifest Editor:
Manifest Editor:
CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)
CreateResourceFromFile(Macro, FirebaseAnalytics.Firebase)
CreateResourceFromFile(Macro, FirebaseAnalytics.FirebaseAnalytics)
CreateResourceFromFile(Macro, FirebaseAdMob.FirebaseAds)

Activity_Create:
B4X:
Dim m As MobileAds
    Wait For (m.Initialize) MobileAds_Ready
    Dim AdaptiveSize As Map = GetAdaptiveAdSize

    IAd.Initialize("iad", "ca-app-pub-3940256099942544/1033173712")
    IAd.LoadAd

    Activity.LoadLayout("splash")

    If IAd.Ready Then
        IAd.Show
    End If

    Activity.LoadLayout("initial")
End Sub

IAD_AdClosed:
IAD_AdClosed:
Sub IAD_AdClosed
    Log("Closed")
    IAd.LoadAd 'prepare a new ad
End Sub

Ad_FailedToReceiveAd:
Sub iAd_FailedToReceiveAd (ErrorCode As String)
    Log("Failed: " & ErrorCode)
End Sub

In the sub iAd_FailedToReceiveAd there is no error in the log.

Thanks for any help!
 

arf programas

Member
Licensed User
It seems that IAD variable wasn't initialized when IAD_Closed was called.

I always put this part of code in Starter service, to make sure that will be always ready:

B4X:
Dim m As MobileAds
Wait For (m.Initialize) MobileAds_Ready

And IAD must be a Global Variable.
 
Upvote 0
Top