Android Question How to use Firebase for ads & Google Play Games Services for Leaderboards, etc...?

Computersmith64

Well-Known Member
Licensed User
Like a lot of other developers I received an email yesterday informing me that AdMob SDK v6.4.1 will no longer work after September 15th. Reading through threads on here it seemed that Erel was advising anyone using AdMob to update to the Firebase AdMob library, as it uses the latest version of the AdMob SDK.

Switching from the mwAdMobInterstitial2 library to the FirebaseAdMob library was pretty straightforward (I think I only had to change 2 lines of code), however when I went to compile the app it failed with a Google Play Services error (I use NFOBoy's wrapper, which requires Google Play Services v14 API). On further investigation, I discovered I could compile the app without the code that accesses NFOBoy's wrapper, however my app then crashed when it went to load an ad because it was expecting google_play_services_version 9256000 & the value I was using in my ids file was 4132500. After I changed it to 9256000, Firebase ads worked fine - but of course, my Google Play Games Services would no longer work because the wrapper references functions that have been deprecated in later versions of Google Play Services.

So I thought that maybe I could specify a different play services version for Firebase & Play Games - I did this in my manifest:

B4X:
AddApplicationText(
'**********Google Play Games Services*********
<meta-data android:name="com.google.android.gms.games.APP_ID"
android:value="@string/app_id" />
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
)
'*********End of Google Play Games Services*************

'************ Firebase Ads ************
AddApplicationText(
  <activity
  android:name="com.google.android.gms.ads.AdActivity"
  android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
  android:theme="@android:style/Theme.Translucent" />
  <activity android:name="com.google.android.gms.ads.purchase.InAppPurchaseActivity"
  android:theme="@style/Theme.IAPTheme"/>
  <meta-data android:name="com.google.android.gms.version"
    android:value="@integer/google_play_services_version_firebase" />
)
'************ Firebase Ads (end) ************

however it seems that while you can customize the label associated with the label, you can only have one meta-data entry for "com.google.android.gms.version" - or more specifically, if you have more than one, it's the last one that is used.

So - the question is: If we have to move to Firebase ads, how can we also continue to have leaderboards & achievements in our apps as well?

- Colin.
 

Computersmith64

Well-Known Member
Licensed User
You cannot use multiple versions of google play services.

Does the library you are talking about only work with Google Play Services v14?
Hi Erel - I've only used it with v14, but it might work with some later versions. I vaguely recall trying it with v19 without success & it definitely doesn't work with whatever version Firebase is using. It seems that Google Play Services has had a lot of changes through the versions & some of the functionality implemented in v14 has been deprecated in later versions.

I'm very concerned about this issue because the apps I currently have in Play Store are how I make my living & if the current functionality in them suddenly no longer works after September 15th, then I'm basically screwed.

- Colin.
 
Upvote 0

Erel

Administrator
Staff member
Licensed User
The issue is not really related to Firebase.

The problem is that:
1. You are using a library that doesn't work with newer versions of google play services.
2. Google no longer distributes AdMob as a separate package: https://firebase.google.com/docs/admob/android/download
It is distributed inside Google Play Services.

You can ask NFOBoy to provide you the source code of his library and try to make the required changes.
 
Upvote 0

sorex

Expert
Licensed User
I switches aswell and had no problems at all.

Just make sure you remove the previous stuff in the manifest and in the main module like these...

B4X:
    #AdditionalRes: C:\program files\android\sdk\extras\google\google_play_services\libproject\google-play-services_lib\res, com.google.android.gms.ads
    #AdditionalJar: android-support-v4

in-app purchased via google have no affect as that library seems to work completely on its own.
 
Upvote 0

Computersmith64

Well-Known Member
Licensed User
I switches aswell and had no problems at all.

Just make sure you remove the previous stuff in the manifest and in the main module like these...

B4X:
    #AdditionalRes: C:\program files\android\sdk\extras\google\google_play_services\libproject\google-play-services_lib\res, com.google.android.gms.ads
    #AdditionalJar: android-support-v4
Hi Sorex - are you using AdMob AND Google Play Games Services (ie: Leaderboards, Achievements, etc...)? If so, which wrapper are you using for Google Play Games Services - Informatix's or NFOBoy's?

- Colin.
 
Upvote 0

sorex

Expert
Licensed User
I just read it that you were using the leaderboars...

no, I don't use them... I had google play services for admob and that mwadmobinterstitials libraries.

I use my own leaderboard system as I don't like google play services.
 
Upvote 0

Computersmith64

Well-Known Member
Licensed User
I just read it that you were using the leaderboars...

no, I don't use them... I had google play services for admob and that mwadmobinterstitials libraries.

I use my own leaderboard system as I don't like google play services.
Yeah - I can use AdMob with Firebase with no problems too. Just can't use AdMob & GPGS...
 
Upvote 0

Computersmith64

Well-Known Member
Licensed User
Erel - I do have the source code from NFOBoy's library & have made very minor changes in the past - however I'm not sure I have the ability to make bigger changes. Despite reading the various threads on writing wrappers for B4A, I've always struggled with it.

It's unfortunate that B4A doesn't support GPGS as one of it's core pieces of functionality. I'm sure I'm not the only B4A user that's going to have this issue.

- Colin.
 
Upvote 0
Top