Android Question Error with Admob and Banner

WebQuest

Active Member
Licensed User
Longtime User
Hello community, I am having problems with the Admob library! Before it always worked, the banners appeared. Now when I launch debug the app stops without errors. How do I understand what the problem is?

I'm using this code:

code:
Sub Load_Banners
    BannerAd.Initialize2("BannerAd","ca-app-pub-3940256099942544/6300978111",BannerAd.SIZE_SMART_BANNER) ' Test Banner
    'BannerAd.Initialize2("BannerAd","ca-app-pub-6756501346137908/5112726844",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") 'Test interstitial
    'IAd.Initialize("IAd","ca-app-pub-3940256099942544/1033173712")
    'IAd.LoadAd
    
End Sub
Sub CaricaInterstitial
    'If IAd.Ready Then IAd.Show 'carica una banner a tutto schermo
End Sub
Sub IAD_AdClosed
    'IAd.LoadAd 'Prepare un altra pubblicità
End Sub

Sub TimerInter_Tick
    'CaricaInterstitial
    TimerInter.Enabled=False
End Sub


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

asales

Expert
Licensed User
Longtime User
1 - Check the unfiltered logs to see the error.
2 - Use Adaptive Banner instead Smart Banner.
3 - Check this example:
 
Upvote 0

WebQuest

Active Member
Licensed User
Longtime User
I checked this example I don't understand anything. It's completely different. I need a single example
 
Upvote 0

asales

Expert
Licensed User
Longtime User
I need a single example
Check the examples from @Erel to the lib:
 
Upvote 0

asales

Expert
Licensed User
Longtime User
I checked this example I don't understand anything. It's completely different. I need a single example
1 - Check the logs and the unfiltered logs to find what is caused the crash.

2 - Even you don't understood, the example worked?
If yes, compare with your code to check what you need to update.
 
Upvote 0

WebQuest

Active Member
Licensed User
Longtime User
B4X:
com.google.android.gms.common.GooglePlayServicesMissingManifestValueException: A required meta-data tag in your app's AndroidManifest.xml does not exist.  You must have the following declaration within the <application> element:     <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
 
Upvote 0

AmirPYTHON

Member
Try To Add This Code In Manifest Editor

Code:
AddApplicationText(
<meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />)
 
Upvote 0

WebQuest

Active Member
Licensed User
Longtime User
This is part of this macro:
B4X:
CreateResourceFromFile (Macro, FirebaseAnalytics.GooglePlayBase)

I could not find the reason why, when I add the macro to the manifest editor, the application grows at start-up.
 
Upvote 0

WebQuest

Active Member
Licensed User
Longtime User
Hi guys I found the bug. In the manifest editor I didn't change the slasch symbol with the tilde.

/ > ~
B4X:
    AddApplicationText(
        <meta-data
            android:name="com.google.android.gms.ads.DELAY_APP_MEASUREMENT_INIT"
            android:value="true"/>
    )


AddReplacement($ADMOB_APP_ID$, ca-app-pub-xxxxxxxxxxxxxxxx~xxxxxxxxxx)
CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)
CreateResourceFromFile(Macro, FirebaseAdMob.FirebaseAds
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…