Android Question Admob tutorial

Lego Jérôme

Member
Licensed User
1)
Hi,
for the second time I try to follow the erel tutorial : https://www.b4x.com/android/forum/threads/integrating-firebase-services.67692/

I am following his tutorial and I am stuck on the 4 point.
Attached images corresponds to where I'm stuck what should I put in the manifest.

I would like to add interstitial ads to my application.​

2)
when i put in my manifest this code :

B4X:
CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)
CreateResourceFromFile(Macro, FirebaseAnalytics.Firebase)

when I try to install in debug mode my phone say : " there was a problem parsing the package "
Why ?
 

Attachments

  • Sans titre.png
    Sans titre.png
    24.8 KB · Views: 377
  • Sans titre.png
    Sans titre.png
    24.8 KB · Views: 336

asales

Expert
Licensed User
Longtime User
1)
Hi,
for the second time I try to follow the erel tutorial : https://www.b4x.com/android/forum/threads/integrating-firebase-services.67692/

I am following his tutorial and I am stuck on the 4 point.
Attached images corresponds to where I'm stuck what should I put in the manifest.

I would like to add interstitial ads to my application.​

2)
when i put in my manifest this code :

B4X:
CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)
CreateResourceFromFile(Macro, FirebaseAnalytics.Firebase)

when I try to install in debug mode my phone say : " there was a problem parsing the package "
Why ?
- You are using B4A 8+?
- Did you create and download the google-services.json file in Firebase console?
- Did you include the Firebase Admod library in the project?
- Search in the forum to "There was a problem parsing the package" and you find several threads (maybe one can help you).
 
Upvote 0

Lego Jérôme

Member
Licensed User
i use B4a 8 yes.
Yes i have my "google-services.json" in my folder but he only makes 1 ko... it's normal ?
Yes i have fireBaseAdmod v1.31
alright i'll look on the forum this sentence.

a) Do you know for the 4th point of the tutorial ?
- What should I put in my manifeste ?
- should I just put : CreateResourceFromFile......​
 

Attachments

  • Sans titre.png
    Sans titre.png
    29.3 KB · Views: 289
  • Sans titre2.png
    Sans titre2.png
    5 KB · Views: 290
Upvote 0

asales

Expert
Licensed User
Longtime User
Yes i have my "google-services.json" in my folder but he only makes 1 ko... it's normal ?
What is "1 ko"?
Yes i have fireBaseAdmod v1.31
FirebaseAdmob library is: 1.51:
https://www.b4x.com/android/forum/threads/updates-to-internal-libraries.59340/#post-592335
- What should I put in my manifeste ?
- should I just put : CreateResourceFromFile......
This lines in manifest:
B4X:
'************ Google Play Services Base ************
CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)
'************ Google Play Services Base (end) ************
'************ Firebase Base ************
CreateResourceFromFile(Macro, FirebaseAnalytics.Firebase)
'************ Firebase Base (end) ************
'************ Firebase Ads ************
CreateResourceFromFile(Macro, FirebaseAdMob.FirebaseAds)
'************ Firebase Ads (end) ************
 
Upvote 0

Lego Jérôme

Member
Licensed User
What is "1 ko"?

"1ko" it's the file size of my "google-services.json"

This lines in manifest:

'************ Google Play Services Base ************
CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)
'************ Google Play Services Base (end) ************
'************ Firebase Base ************
CreateResourceFromFile(Macro, FirebaseAnalytics.Firebase)
'************ Firebase Base (end) ************
'************ Firebase Ads ************
CreateResourceFromFile(Macro, FirebaseAdMob.FirebaseAds)
'************ Firebase Ads (end) ************

i write this few lines in my manifest.


Now my library is update to 1.51 !


And when i run with this configuration with this code :

B4X:
#Region  Project Attributes
    #ApplicationLabel: Pub AdMob
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
    #AdditionalJar: com.google.android.gms:play-services-base
#End Region


#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.

End Sub

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

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("1")
    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-8935643716482518/1013934081")
    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

And it's my phone who say again : " there was a problem parsing the package "
I will check again the forum.
But this error only happens when I enter the few lines in the manifeste....
 
Upvote 0

Lego Jérôme

Member
Licensed User
Ok i have try to install by USB and now i have a other error message from my compiler :

adb: failed to install result_RAPID_DEBUG.apk: Failure [INSTALL_PARSE_FAILED_
MANIFEST_MALFORMED: Failed parse during installPackageLI:
/data/app/vmdl400041629.tmp/base.apk (at Binary XML file line
#14): Bad class name Ad.Mob.pub.permission.C2D_MESSAGE in package Ad.Mob.pub]
I will try to search the forum if I find tracks
 
Upvote 0

asales

Expert
Licensed User
Longtime User
It worked here.

I made a few changes in code:
- initialized the firebase analytics
- moves the code to Activity_Create
- change the id of test to interstitial ad
- click in Button1 to show interstitial ad
 

Attachments

  • PubAdmob1.zip
    10 KB · Views: 336
Upvote 0

Lego Jérôme

Member
Licensed User
Good at least like that I'm sure it does not come from the code or manifeste, thank you for your help asales.

I still have this problem compilation that is driving me crazy and ok I'll have to find his solution.
maybe this problem has to come from my "google-services.json".
 
Upvote 0

Lego Jérôme

Member
Licensed User
I'm trying to pair my app with AdMob, I left the test banner, so I see that she works but when I put my application id (ca-app-pub-893......../.........) nothing is displayed when I click the button. when I run the program in debug mode, logically I should have in my logs : Log("Ad loaded") or Log("Failed to load ad: " & ErrorMessage).
Even in my logs nothing is displayed. I yet touch the interaction with the button :
B4X:
Sub Button1_Click       
    If IAd.Ready Then
        IAd.Show
    Else
        IAd.LoadAd
    End If
End Sub
Also I made the move to create my application on firebase and AdMob this morning
 
Upvote 0

Computersmith64

Well-Known Member
Licensed User
Longtime User
EDIT: I see that you did test it with the test id & it worked, so you should double-check your ad id from the AdMob console.
========================================================
You should initially try it using the test ads id (ca-app-pub-3940256099942544/1033173712). If you successfully get test ads, then you know there's no issue with your implementation & you can look at possible issues with your account, or simply that there are no ads to display when you're calling them.

- Colin.
 
Upvote 0

Lego Jérôme

Member
Licensed User
Yes it works very well when I use the ad id test. with my id i never received an ad.

Other thing I noticed that when we create an account on firebase, there is a moment when he asks us to test if the application is good to communicate with firebase (we just have to run application) but here I install and reinstall the application and they never detected that my application communicate with firebase ...


in my logs :


tentative chagement n° 418
tentative chagement n° 419
tentative chagement n° 420 7 Minutes
tentative chagement n° 421
tentative chagement n° 422
tentative chagement n° 423
tentative chagement n° 424
tentative chagement n° 425
tentative chagement n° 426
tentative chagement n° 427
tentative chagement n° 428


because i make this loop :
B4X:
Sub Button1_Click      
    Dim a As Int = 0
    Dim b As Int = 0
    Dim c As Int
    Dim phrase As String
   
    Do While a=0
        If IAd.Ready Then
            Log("Pub prete à être affiché !!!!!!")
            a = 1
            IAd.Show          
        Else
            c = b / 60
            If c= b/60 Then
                phrase = "   " & c & " Minutes"
            Else
                phrase = ""
            End If          
           
            Log("tentative chagement n° " & b & phrase)
            IAd.LoadAd  
            b = b + 1  
            Sleep(1000)
        End If
    Loop

End Sub
 

Attachments

  • test id.png
    test id.png
    72.3 KB · Views: 299
Last edited:
Upvote 0

asales

Expert
Licensed User
Longtime User
Did you use the correct admob id?

The new admob console shows 2 differents ids when you create the block. One with " ~ " and other with " / ". You should uses this last one.
 
Upvote 0

hatzisn

Expert
Licensed User
Longtime User
Upvote 0

Lego Jérôme

Member
Licensed User
Did you use the correct admob id?

The new admob console shows 2 differents ids when you create the block. One with " ~ " and other with " / ". You should uses this last one.

yes i use the id with "/"

but what I do not understand :
they gave me an app id that I do not use. and from what I understand I should get it into the manifest code. am I wrong ?
 
Upvote 0

asales

Expert
Licensed User
Longtime User
yes i use the id with "/"

but what I do not understand :
they gave me an app id that I do not use. and from what I understand I should get it into the manifest code. am I wrong ?
You don't need an app id, only the admob id.
If the test admob id works, I think the code is ok.
I see others thread (in past) in the forum, that mentioned a delay to show the ads in an app.
Create others blocks in admob and try it again.
 
Upvote 0
Top