Android Question B4a v6 and backwards compability regarding admob

vikingivesterled

Active Member
Licensed User
Longtime User
Having trouble getting admob to work with the new google play module:

B4A version: 6.00
Parsing code. (1.01s)
Compiling code. (14.87s)
Compiling layouts code. (1.70s)
Organizing libraries. (0.01s)
Generating R file. Error
AndroidManifest.xml:30: error: Error: No resource found that matches the given name (at 'value' with value '@Integer/google_play_services_version').


And most searches brings me to pre v6.00 answers.

It worked fine until I included the admob .LoadAd bit, after which it will no longer compile.
My manifest, after several attempts including reading v6.00 released page, now looks like this (not using FireBase ads, so commented that out):

B4X:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: http://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="23"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
SetApplicationAttribute(android:theme, "@android:style/Theme.Holo")
'End of default text.
'SetManifestAttribute("android:installLocation", "auto")
SetManifestAttribute(android:installLocation, auto)
'AdMob
'AddApplicationText(
'<meta-data android:name="com.google.android.gms.version"
'  android:value="[USER=21225]@Integer[/USER]/google_play_services_version"/>
' <activity android:name="com.google.android.gms.ads.AdActivity"
'  android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
')
'End of AdMob
'InAppBilling declarations - Start
AddReceiverText(BillingService,  <intent-filter>
                <action android:name="com.android.vending.billing.IN_APP_NOTIFY" />
                <action android:name="com.android.vending.billing.RESPONSE_CODE" />
                <action android:name="com.android.vending.billing.PURCHASE_STATE_CHANGED" />
            </intent-filter>)
'InAppBilling declarations - End
'************ Google Play Services Base ************
AddApplicationText(
   <activity android:name="com.google.android.gms.common.api.GoogleApiActivity"
  android:theme="@android:style/Theme.Translucent.NoTitleBar"
  android:exported="false"/>
    <meta-data
  android:name="com.google.android.gms.version"
  android:value="[USER=21225]@Integer[/USER]/google_play_services_version" />
)
'************ Google Play Services Base (end) ************
'************ 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"/>
')
'************ Firebase Ads (end) ************


It compiles with just the default part, but app crashes when it is to load an ad.

It will not compile with the first admob part and the fix to that used to be to copy over the updated google-play-services.jar but that is no longer updated / installed. (It would be nice if all old articles, no longer relevant to the last version, becomes archived or marked "no longer valid/needed from version n.nn" somehow.)

I have both api23 and api24 installed in Android SDK Manager, both updated to today, and the Extras of Google Play Services, Google Repository and Android Support Repository installed.
I commented out the line:
B4X:
    '#AdditionalRes: C:\Program Files\Android\android-sdk\extras\google\google_play_services\libproject\google-play-services_lib\res, com.google.android.gms

My ad loading sub looks like this:
B4X:
    MainAdView.Initialize("Ad", "ca-app-pub-nnnnnnnnnnn/nnnnnnnn")
    If CommercialAdLabel.Height < 50dip Then
        Activity.AddView(MainAdView, CommercialAdLabel.Left, CommercialAdLabel.Top, CommercialAdLabel.Width, 50dip)'CommercialAdLabel.Height)
    Else
        Activity.AddView(MainAdView, CommercialAdLabel.Left, CommercialAdLabel.Top, CommercialAdLabel.Width, CommercialAdLabel.Height)
    End If
    MainAdView.LoadAd 'loads an ad
 
Last edited:

DonManfred

Expert
Licensed User
Longtime User
, - Use code Tags when Posting code

- You need to migrate to firebase ads
See firebase tutorials
 
Upvote 0

vikingivesterled

Active Member
Licensed User
Longtime User
Following the tutorial, downloading the library FirebaseAdmob, adding it to the Manifest and removing the previous AdMob library did let me compile and it is showing an ad -
Thank you DonManfred.

So is the old AdMob library now defunct if you have to use a new FirebaseAdMob library.
Did we not have a change about a year ago where AdMob needed the extra GooglePlay link:
'#AdditionalRes: C:\Program Files\Android\android-sdk\extras\google\google_play_services\libproject\google-play-services_lib\res, com.google.android.gms

Then we had to upgrade all the apps with the new linking as a requirement from Google, due to old way ending.
Will this be the same again, so after a while published apps using the AdMob library will stop serving ads unless they are recompiled with v6.00 and updated to use the FirebaseAdMob library?
 
Last edited:
Upvote 0

quique

Member
Licensed User
Longtime User
Hi Erel, are you aware that now Firebase started limiting the quantity of projects available to each users, based on their past conduct and whatever else they evaluate ? In some instances a user can only open 3 projects before starting to pay for Google cloud services, etc. So, this is getting cumbersome for real. Is there any other way of integrating the newer native play services etc. libraries on BxA 6.x ?

Regards,

Enrique
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
The new google play services have nothing to do with Firebase.
You don't need a Firebase project for that.

I guess that you are talking about FirebaseAdMob.
Can you post a link that describes those new limitations?
Note that a single Firebase project can include many applications. You don't need to create multiple projects.
 
Upvote 0

quique

Member
Licensed User
Longtime User
Hi Erel,

Yes I was talking about FirebaseAdMob. The limitation seems to be on the project's quantity. I just realized by reading your comment, that I can add several apps per project. So I am confident the problem is solved (I cannot try it on my firebase account at this time, but I will do first thing tomorrow morning) !

But yet, now just for information purposes, the project limitation is real and when reaching it you will be faced with a payment form. The FAQ states:


Why am I being asked to make a payment for more projects?
You may be asked to make a payment if your request for more projects indicates that you need projects that will use paid cloud services. The payment can be applied to any charges you incur in the future and will be visible as a credit in your account.

This payment is required to ensure paid services will be available for the projects you requested in the quota increase request form. This is a common requirement, because Google Cloud Platform services are paid (e.g., Compute Engine, Cloud SQL, and BigQuery).

The payment required varies depending on your billing history, the use cases described in your request form, the number of projects you request, and other factors.
 
Upvote 0
Top