Android Question Fail to load ad

Discussion in 'Android Questions' started by catyinwong, Feb 10, 2019.

  1. catyinwong

    catyinwong Active Member Licensed User

    Trying to add advertisement into an app. There is an error when the app tries to load the add: java.lang.IllegalStateException: 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" />

    The error occurs on the line "BannerAd.LoadAd". Anyone knows why?


    Code:
    Sub Globals
        
    'These global variables will be redeclared each time the activity is created.
        'These variables can only be accessed from this module.
        Dim BannerAd As AdView
        
    Dim 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")
        Dim p As Panel = LoadAd("ca-app-pub-5725771019370401/3534296381")
        
    Activity.AddView(p,0,0,p.Width,p.Height)
    End Sub

    Sub LoadAd(AdID As StringAs Panel
        
    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
        
        BannerAd.Initialize(
    "BannerAd", AdID)

        BannerAd.Width = 
    100%x
        BannerAd.Height = height
        
        
    Dim p As Panel: p.initialize("BannerAd")
        p.Width = BannerAd.Width
        p.Height = BannerAd.Height
        p.AddView(BannerAd,
    0,0,p.Width,p.Height)
        
        BannerAd.LoadAd
        
        
    Return p
    End Sub

    Sub Activity_Resume

    End Sub

    Sub Activity_Pause (UserClosed As Boolean)

    End Sub
     
  2. catyinwong

    catyinwong Active Member Licensed User

  3. Computersmith64

    Computersmith64 Well-Known Member Licensed User

  4. catyinwong

    catyinwong Active Member Licensed User

    I have already followed the steps, still new kind of error pop up every time...


    1. Use B4A Sdk Manager tool to install all recommended items.
    I did, and even uninstalled and reinstalled the B4A once to make sure all libraries and items are of the latest version.

    2. Register with Firebase and create a new project: https://console.firebase.google.com/
    Make sure that the package name matches your app's package name.

    I did. The package names match.

    3. Download google-services.json and put it in the projects folder (folder of the b4a file).
    I did.

    4. Add the manifest snippets to the manifest editor based on the services that you need.
    Not sure what to add. Nothing written in the tutorial thread.

    5. Follow the instructions of the specific libraries.
    Simply copies the codes from the tutorial thread. But it doesn't work.
     
  5. Computersmith64

    Computersmith64 Well-Known Member Licensed User

    The 4th paragraph in the Firebase AdMob tutorial says:

    If you read that you'd know which manifest snippets to add.

    EDIT: Actually, you obviously did go to the Firebase integration tutorial, but you didn't read the whole thing. Read past where it says:

    If you are using an older version than v8+, scroll down & click on the button that says "Spoiler: Older Versions:"

    - Colin.
     
    Last edited: Feb 12, 2019
  6. Computersmith64

    Computersmith64 Well-Known Member Licensed User

    There's something not right in your manifest. Post the contents on here.

    - Colin.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice