Android Question My Admob Ads not Working

hasexxl1988

Active Member
Licensed User
Longtime User
Hello,

I have the problem that ads are not loaded.

Admob was created correctly.
In Firebase, the app was also created.

I tested it with the banner APP ID as well as IAD ID.

The Admob Examples default IDs https://www.b4x.com/android/forum/t...tegrated-with-firebase-backend.67710/#content
are loaded without problems.

What have I done wrong?

Code B4A:

B4X:
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Private BannerAd As AdView
    Private IAd As InterstitialAd
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("Layout1")
   
    'Admob Ads
    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
    IAd.Initialize("iad", "ca-app-pub-3940256099942544/1033173712")
    IAd.LoadAd
End Sub

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

Sub IAD_AdClosed
    IAd.LoadAd 'prepare a new ad
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Code Manifest:

B4X:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: http://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="19"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>)

SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")

AddApplicationText(
   <activity android:name="com.google.android.gms.common.api.GoogleApiActivity"
  android:theme="@android:style/Theme.Translucent.NoTitleBar"
  android:exported="false"/>
    <meta-data
  android:name="com.google.android.gms.version"
  android:value="@integer/google_play_services_version" />
)
CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)
CreateResourceFromFile(Macro, FirebaseAnalytics.Firebase)
CreateResourceFromFile(Macro, FirebaseNotifications.FirebaseNotifications)
CreateResourceFromFile(Macro, FirebaseAnalytics.FirebaseAnalytics)
CreateResourceFromFile(Macro, FirebaseAdMob.FirebaseAds)
CreateResourceFromFile(Macro, FirebaseAuth.FirebaseAuth)

I think the error lies in the manifest file. I'm not sure where to enter the APP ID ..
 
Last edited:

kisoft

Well-Known Member
Licensed User
Longtime User
Hi
Are these new ad units? Have the old ones stopped working? If your test ad works correctly, you'll have to wait for a real ad (up to 48 hours)
 
Upvote 0

hasexxl1988

Active Member
Licensed User
Longtime User
Hi
Are these new ad units? Have the old ones stopped working? If your test ad works correctly, you'll have to wait for a real ad (up to 48 hours)
Ah Okay, I created the Admob & Firebase account as well as the Ad ads just 2 hours ago. Thought that would be faster :) thanks
 
Upvote 0
Top