Android Example [B4XPages] The (almost) Definitive Admob Example

asales

Well-Known Member
Licensed User
To help the new members to make money with B4A, I tried to compile all the relevant Admob code (except mediation) of the forum in this example and put comments and links.
This is a work in progress.
Any code and sample to improve this example are welcome.

Follow these instructions to start:
1. Integrating Firebase Services
- https://www.b4x.com/android/forum/threads/integrating-firebase-services.67692/
2. FirebaseAdMob - Admob ads integrated with Firebase backend
- https://www.b4x.com/android/forum/t...tegrated-with-firebase-backend.67710/#content
3. FirebaseAdMob v1.6
- https://www.b4x.com/android/forum/threads/firebaseadmob-v1-6.108552/
4. B4A 9.90 and SDK Manager up to date.

Updated 2.0 (B4XPages_Admob_Example):
- B4XPages
- Transition in Interstitial ad (requires Reflection library)
- Code to mute the ad sound
- Banner in a panel

admob_example2.png
 

Attachments

Last edited:

Mike1970

Well-Known Member
Licensed User
GREAT WORK. With the tutorials on the forum i couldn't get a functioning example. But with this i can finally start to study this thing.

However there is an error in the "Banner Module"

Line 116
B4X:
java.lang.RuntimeException: Method: getCurrentOrientationAnchoredAdaptiveBannerAdSize not found in: com.google.android.gms.ads.AdSize
 

Michele Balzano

New Member
Licensed User
Ho provato ad utilizzare il codice con l'ultima versione di B4A, ma ricevo sempre l'errore
Errore analisi google-services.json:
Il file 'C: \ Users \ miche \ OneDrive \ Desktop \ AdmobExample_Forum \ google-services.json' non è stato trovato. dove posso scaricare il file?
grazie
 

Mike1970

Well-Known Member
Licensed User
Ho provato ad utilizzare il codice con l'ultima versione di B4A, ma ricevo sempre l'errore
Errore analisi google-services.json:
Il file 'C: \ Users \ miche \ OneDrive \ Desktop \ AdmobExample_Forum \ google-services.json' non è stato trovato. dove posso scaricare il file?
grazie
You must follow the Erel’s guide about the integration of Firebase here, there is a step where you have to download that file and put it in the app folder
 

arastoo

Active Member
Licensed User
To help the new members to make money with B4A, I tried to compile all the relevant Admob code (except mediation) of the forum in this example and put comments and links.
This is a work in progress.
Any code and sample to improve this example are welcome.

Follow these instructions to start:
1. Integrating Firebase Services
- https://www.b4x.com/android/forum/threads/integrating-firebase-services.67692/
2. FirebaseAdMob - Admob ads integrated with Firebase backend
- https://www.b4x.com/android/forum/t...tegrated-with-firebase-backend.67710/#content
3. FirebaseAdMob v1.6
- https://www.b4x.com/android/forum/threads/firebaseadmob-v1-6.108552/
4. B4A 9.80 and SDK Manager up to date.

View attachment 88140

Hi asales
Thank you very much for this example

The program gives an error without any log as long as this line of code is active in the manifest.
As soon as you comment on this line, the program will work properly. What is the reason?

B4X:
'************ Firebase Base (end) ************'************ Firebase Ads ************
'CreateResourceFromFile(Macro, FirebaseAdMob.FirebaseAds)
 

arastoo

Active Member
Licensed User
Hi @asales

You may complete click-through activity on native ads. 🙏
After clicking, we have to go back to the app and load the new ads.
How is this process done?

Thank you for your kindness and guidance.
 

asales

Well-Known Member
Licensed User
Hi asales
The program gives an error without any log as long as this line of code is active in the manifest.
- Check the unfiltered logs
- The B4A version and the FirebaseAdMob lib is up to date?
- Did you follow this instructions?
 

asales

Well-Known Member
Licensed User
Hi @asales
You may complete click-through activity on native ads. 🙏
After clicking, we have to go back to the app and load the new ads.
How is this process done?
This ads is different from the others. Try with the "_clicked" event.
Google is not serving tests ads to my app (lack of inventory) and, for this, I can't check this option.
 

Lyndon Bermoy

Active Member
Licensed User
The real ads are now showing using the debug keys. All thanks to you @asales :) But when I created my private sign key, the real ads now won't appear but when I use debug key then the real ads will appear again. How to fix this? I want to upload my first app in Playstore since I already have the Google Developer account.
 

asales

Well-Known Member
Licensed User
A new example was attached in the first post.
Updated with:
- B4XPages
- Transition in Interstitial ad (requires Reflection library)
- Code to mute the ad sound
- Banner in a panel ( @AnandGupta )
 
Last edited:

azad222

Member
To help the new members to make money with B4A, I tried to compile all the relevant Admob code (except mediation) of the forum in this example and put comments and links.
This is a work in progress.
Any code and sample to improve this example are welcome.

Follow these instructions to start:
1. Integrating Firebase Services
- https://www.b4x.com/android/forum/threads/integrating-firebase-services.67692/
2. FirebaseAdMob - Admob ads integrated with Firebase backend
- https://www.b4x.com/android/forum/t...tegrated-with-firebase-backend.67710/#content
3. FirebaseAdMob v1.6
- https://www.b4x.com/android/forum/threads/firebaseadmob-v1-6.108552/
4. B4A 9.90 and SDK Manager up to date.

Updated 2.0 (B4XPages_Admob_Example):
- B4XPages
- Transition in Interstitial ad (requires Reflection library)
- Code to mute the ad sound
- Banner in a panel

View attachment 88140
An error occurred after execution. stop program.
I tried it on Android 4.2 and 10.
 

Attachments

Top