Android Question Admob lite sdk

Erel

B4X founder
Staff member
Licensed User
Longtime User
Yes, it is possible to use the lite SDK. It saves about 1mb in the APK size.

1. Edit FirebaseAdMob.xml and change the dependsOn to: com.google.android.gms:play-services-ads-lite

SS-2016-09-30_08.28.22.png


2. The manifest editor should include these snippets:
B4X:
'************ 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="@integer/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) ************
AddPermission(android.permission.ACCESS_NETWORK_STATE)
AddPermission(android.permission.INTERNET)

Remove FireBase Base snippet.
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
I tried this and the apk just got 5Kb smaller?

Edit: ignore the above, it was still loading the old 1.0 lib

I installed 1.3 edited the manifest but now get this error...

Maven artifact not found: com.google.gms/play-services-ads-lite

do I need to install a new version of google play services?

Edit2: updated google play services but that jar is nowhere to find
 
Last edited:
Upvote 0

sorex

Expert
Licensed User
Longtime User
@Erel,

how does B4A know where the android sdk files are?

it can't seem to find that play-services-ads-lite folder altho it's there where it should be.
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
yes, I have the folder aswell altho it still nags that it can't find it.

I renamed the sdk folder
downloaded the latest installer
installed api 9 & 14 + the repos and google play services

other projects compile fine, this one still gives this maven error

sdk.png
 
Last edited:
Upvote 0

sorex

Expert
Licensed User
Longtime User
changing that line in the firebaseadmob.xml back to what it was makes it work with the oversized lib.
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
B4X:
    <version>1.3</version>
<!--    <dependsOn>com.google.firebase:firebase-ads</dependsOn>-->
    <dependsOn>com.google.gms:play-services-ads-lite</dependsOn>   
</root>
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
I was missing the .android. ... a typo since it was a screenshot and not selectable text in post 1.

now it compiles but the app goes in error without anything in the logs. "unfortunately, app has stopped"
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
ok, now the app works fine.

the size is about 1.4Mb smaller which is great :)

but it doesn't load any banner or interstitial and gives error 1.
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
ok, I think I know the problem.

as this relies on google play the device needs to have google play services installed or it won't work I guess?
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
now it's working. the device needs google play services installed or it won't download ads.

this is a disadvantage on an advantage :)
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
the disadvantage mentioned above (not getting ads if no google play services is installed or outdated) is explained below.

I wonder how many people get/have devices where google apps is not installed or blocked?


Limitations of the Lite SDK
The Lite SDK should only be used in apps distributed through the Google Play store.

Unlike other Google Play services, the standard Google Mobile Ads SDK implementation in the Google Play services APK is also included in the Google Play services client library. This allows for support on devices without the Google Play services APK. At runtime, the SDK will compare the versions of the client library and the Google Play services APK and use the newer version.

The Lite SDK strips the Google Mobile Ads SDK implementation from the client library, leaving only an interface to the Google Play services APK. The Lite SDK relies on the implementation of the APK. If you deploy your app outside of the Google Play store, it is not guaranteed that your user's devices will have the Google Play services APK installed.

On devices with an up-to-date version of Google Play services, the Lite SDK's behavior is identical to that of the standard SDK. However, on devices where Google Play services is outdated or not present, the Lite SDK may reference APIs that are unavailable or have been changed from those in the Google Play services APK. This will result in a no-op and an error being logged, which may cause ads not to serve to those devices.
 
Upvote 0

susu

Well-Known Member
Licensed User
Longtime User
I wonder how many people get/have devices where google apps is not installed or blocked?

Almost devices sell in China didn't have Google Play service. Amazon's phone & tablets didn't have too.
Of course you can always side load Google Play service.
 
Upvote 0
Top