Android Question Probleme with FirebaseAdmob

Lego Jérôme

Member
Licensed User
I followed this tutorial : https://www.b4x.com/android/forum/threads/integrating-firebase-services.67692/

1) I have install all recommended items with B4A Sdk Manager tool.
2) My Firebase was created 2 days ago. with good package.name
3) I have download "google-services.json" from web ("firebase")
4) I did not really understand what I had to put in the manifest of the coup I joined you the code
5) When I run a test the ads are displayed, but when i put my "ca-app-pub-xxxxx/xxxxx", ads are no longer displayed on the screen

i have B4A version 8

Manifest Code :

HTML:
'AdMob
AddApplicationText(
<meta-data android:name="com.google.android.gms.version"
  android:value="@integer/google_play_services_version"/>
<activity android:name="com.google.android.gms.ads.AdActivity"
  android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
)
'End of AdMob

B4X:
Sub Globals
    Private BannerAd As AdView
    Private IAd As InterstitialAd
End Sub

Sub Activity_Create(FirstTime As Boolean)

    
    BannerAd.Initialize2("BannerAd", "ca-app-pub-8935643716482518~7951009036", BannerAd.SIZE_SMART_BANNER)
    Dim height As Int
    If GetDeviceLayoutValues.ApproximateScreenSize < 6 Then
        'phones
        If 100%x > 100%y Then height = 32dip Else height = 50dip
    Else
        'tablets
        height = 90dip
    End If
    Activity.AddView(BannerAd, 0dip, 100%y - height, 100%x, height)
    BannerAd.LoadAd
    IAd.Initialize("iad", "ca-app-pub-3940256099942544/1033173712")
    IAd.LoadAd
    
End Sub

Sub Activity_Pause (UserClosed As Boolean)
End Sub


Sub Activity_Resume
    
End Sub

Sub Activity_Click
    If IAd.Ready Then IAd.Show
End Sub
 

Computersmith64

Well-Known Member
Licensed User
Longtime User
Be indulgent on my code I start in programming and it must be very ugly to watch. =)
It's all good - we all had to start somewhere! :) You should go through the warnings & address them though, because there are some there that might cause unexpected results when you run the app (eg: you have some return statements in subs that are leaving code after them "orphaned" (the warning says "unreachable")).

Also, add the following code to your Main activity so you can see if/when an ad is actually loaded:

B4X:
Private Sub iad_ReceiveAd
    Log("ad loaded")
End Sub

Anyway - I ran the app with one of my interstitial ids & it worked fine. I can't test it with a banner because I don't use them, but I can't see why it wouldn't work. I also couldn't test it with the firebase macros in the manifest because you didn't include your google-services.json file in the project.

It seems that you aren't getting ads because either you are using the wrong ids, or AdMob just isn't serving them for some reason. If you are sure you're using the correct ids, you might want to contact AdMob support to ask them why there are no ads coming through.

- Colin.
 
Upvote 0

Lego Jérôme

Member
Licensed User
ok so it would not be at the programming level in the software but surely a problem of transfer with Adblock.
to be sure of the codes Id that one must return are well those who are in the image attached ?
 

Attachments

  • Sans titre.png
    Sans titre.png
    82.9 KB · Views: 182
Upvote 0

Lego Jérôme

Member
Licensed User
Another question I see by creating a new ad block that there are 2 codes where should we put the first with the "~"
because that one I do not use it and I feel like that's what's blocking me
 

Attachments

  • Sans titre.png
    Sans titre.png
    44.7 KB · Views: 175
Upvote 0

Computersmith64

Well-Known Member
Licensed User
Longtime User
Another question I see by creating a new ad block that there are 2 codes where should we put the first with the "~"
because that one I do not use it and I feel like that's what's blocking me

The id with the "~" is the AdMob app id. You don't need to use this. The only id you need is the ad unit id (the one with the "/" in it).

- Colin.
 
Upvote 0

Lego Jérôme

Member
Licensed User
after several changes I still can not run the ads. So must be with the creation of my "Admob" id.
thank you Colin for all this help brought anyway
 
Upvote 0

Computersmith64

Well-Known Member
Licensed User
Longtime User
after several changes I still can not run the ads. So must be with the creation of my "Admob" id.
thank you Colin for all this help brought anyway
Very strange. Have you contacted AdMob support?

- Colin.
 
Upvote 0
Top