Android Question FirebaseAdMob - failed: error code 1

cenyu

Active Member
Licensed User
Longtime User
Hi i'm trying to implement FirebaseAdMob.
I create PublisherId
Next i use code from https://www.b4x.com/android/forum/t...tegrated-with-firebase-backend.67710/#content


B4X:
Sub Process_Globals

End Sub

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

Sub Activity_Create(FirstTime As Boolean)
   BannerAd.Initialize2("BannerAd", "ca-app-pub-3940256099942544/6300978111", 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
 
End Sub

Sub BannerAd_FailedToReceiveAd (ErrorCode As String)
    Log("failed: " & ErrorCode)
End Sub
Sub BannerAd_ReceiveAd
    Log("received")
End Sub
but receive failed: 1 when i use my PublisherId

This 1 is error code but what is wrong?
 
Last edited:

Computersmith64

Well-Known Member
Licensed User
Longtime User
Hi i'm trying to implement FirebaseAdMob.
I create PublisherId
Next i use code from https://www.b4x.com/android/forum/t...tegrated-with-firebase-backend.67710/#content


B4X:
Sub Process_Globals

End Sub

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

Sub Activity_Create(FirstTime As Boolean)
   BannerAd.Initialize2("BannerAd", "ca-app-pub-3940256099942544/6300978111", 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
 
End Sub

Sub BannerAd_FailedToReceiveAd (ErrorCode As String)
    Log("failed: " & ErrorCode)
End Sub
Sub BannerAd_ReceiveAd
    Log("received")
End Sub
but receive failed: 1 when i use my PublisherId

This 1 is error code but what is wrong?
Did you actually create an ad unit in your AdMob console? If you did, you will have an ad unit ID that will look similar to the ID you used for testing (the easy way to tell the difference between an ad unit ID & a publisher ID is that the ad unit ID uses a "/" & the publisher ID uses a "~").

Ignore what the Google doco says about needing the Publisher ID - you don't need it in your app. You only need the ad unit ID.

- Colin.
 
Upvote 0

cenyu

Active Member
Licensed User
Longtime User
Oh no...i'm not using ad unit ID....This is my mistake...Thanks friends for help...
 
Upvote 0
Top