B4A Library AdMob library

This library requires some configuration. Please see the tutorial: http://www.basic4ppc.com/forum/basi...-admob-tutorial-add-ads-your-application.html

Reference: Basic4android - AdMob

AdMob v2.00 - Based on Google Play Services. This version requires B4A v3.20.

AdMob v1.40 - Add support for SIZE_SMART_BANNER.
These ads will fill the whole available width: https://developers.google.com/mobile-ads-sdk/docs/admob/smart-banners

You can use the following code:
B4X:
Adview1.Initialize2("Ad", "xxxxxxxx", AdView1.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(AdView1, 0dip, 100%y - height, 100%x, height)

See this post for an additional requirement if using google play services v28: https://www.b4x.com/android/forum/threads/admob-library.7301/page-10#post-381519
 

Attachments

  • AdMob_old.zip
    4.3 KB · Views: 698
  • AdMob.zip
    4.7 KB · Views: 2,491
Last edited:

sorex

Expert
Licensed User
This class is included in the latest version of android-support-v4.jar. Download it from Android SDK Manager and copy it to the additional libraries folder.

You need to add this line to the project:
B4X:
#AdditionalJar: android-support-v4

I have some bizarre issue here.

On my test device I suddenly get a lot of crashes AFTER the (interstitial) ad has been loaded (it's not auto displaying)
It can't be trapped with TRY/CATCH either.


it seems to go away by adding that #addtionalJar line in the main module.

What is causing this and why didn't the crashes happen before during the last months?

Could it be that a specific type of pulled in ad requires more than the others?
 

sorex

Expert
Licensed User
ok I will have a look at it.

It's just that compilation without the exclude takes a lot longer.
 

Davin

Member
Licensed User
anyone get this email ? and are the current lib need to updated too ?



Hi,
AdMob is committed to providing you the most effective monetization solutions. As we innovate, it’s important that we leverage the latest technologies to bolster our platform. As part of this movement, we are deprecating versions 6.4.1 and lower of the Android Google Mobile Ads SDK on September 15th, 2016.
In order to ensure that your ads continue to serve after September 15th, 2016, please upgrade to Google Mobile Ads SDK 7.0.0 or higher.

 

Computersmith64

Well-Known Member
Licensed User

quique

Member
Licensed User
Hi Erel! Sorry to somewhat repeat the question / concern:

Is it necessary to perform all the integration steps on this new "firebase" platform ... like "2. Register with Firebase and create a new project: https://firebase.google.com/docs/ Make sure that the package name matches your app's package name." ?

This sounds like a ton of work, to replicate into each app, just to be compliant with the "new admob" requirements.

I am a bit appalled about this apparently mandatory "google twist" ...

Regards, Enrique.
 

Pendrush

Well-Known Member
Licensed User
Hi Erel! Sorry to somewhat repeat the question / concern:

Is it necessary to perform all the integration steps on this new "firebase" platform ... like "2. Register with Firebase and create a new project: https://firebase.google.com/docs/ Make sure that the package name matches your app's package name." ?

This sounds like a ton of work, to replicate into each app, just to be compliant with the "new admob" requirements.

I am a bit appalled about this apparently mandatory "google twist" ...

Regards, Enrique.

It's take you only few minutes to configure firebase project.
 

Computersmith64

Well-Known Member
Licensed User
... plus the code changes, plus compiling, plus testing .... multiplied by nn or even nnn apps.
Yes - I'm also concerned about where this leaves those of us who use Google Play Services for leaderboards, achievements, etc... From my testing of a Firebase integration for ads yesterday, there appears to be a conflict between Firebase & the version of Google Play Services that I need to use for leaderboards & achievements & it doesn't appear that Firebase supports Google Play Games Services. I'm going to look into it more today & see if I can find a solution that doesn't require migrating all my apps to Android Studio. I'll comment on here once I know more.

- Colin.
 

Erel

Administrator
Staff member
Licensed User
I'm going to look into it more today & see if I can find a solution that doesn't require migrating all my apps to Android Studio.
I don't see how it will help. You will still need to update the SDK.

if we dont update this thing. are we affected by the updates ? ( not getting any ads ) ?
Based on Google mail, yes. Note that switching to FirebaseAdmob is very simple.
 

Computersmith64

Well-Known Member
Licensed User
I don't see how it will help. You will still need to update the SDK.

Well the problem is that B4A doesn't have any "native" support for Google Play Games Services & using Firebase for ads breaks the leaderboard & achievement functionality in my apps. Moving to Android Studio would enable me to implement AdMob & Google Play Games functionality without having to rely on 3rd party wrappers that get broken when Google makes a change to one of the libraries they use. B4A is a great development tool & it beats Android Studio hands-down when it comes to building layouts, but it also has a major shortcoming in that it doesn't support all of the Android functionality out-of-the-box. As I said in another post, I make my living from my apps - so I can't afford to suddenly find myself having to make a decision to either have zero revenue (because ads stop working), or remove a big chunk of functionality (because Google Play Games Services stops working) & negatively impact my user base. If I could find a solution that allows me to keep using B4A (& I'm still trying to see if I can modify the existing GPGS wrappers) then I'd happily keep using B4A, but if I can't then I'm not going to have any choice.
 

Computersmith64

Well-Known Member
Licensed User
As a follow-up to the Mobile Ads SDK v6.4.1 & earlier deprecation, a couple of points:

1) The deprecation date has now been pushed from September 16th to October 17th;
2) Any apps that use Google Play Services to serve ads will not be affected. It is only the stand-alone versions of the Mobile Ads SDK that will be deprecated.

So while it might ultimately be better to update to Firebase Ads, it's not absolutely necessary if you are using the versions of the SDK that are integrated into Google Play Services - which I think is the case with both the AdMob library (v2.0) & the mwAdmobInterstitial2 library. Too late for me though, as I have already updated to Firebase Ads... :)
 
Top