[DISTRIBUTION GUIDE] General problems stumbled when distributing android with AdMob

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
Hipreme
Prole
Posts: 15
Joined: Wed Jun 03, 2020 9:57 pm
Contact:

[DISTRIBUTION GUIDE] General problems stumbled when distributing android with AdMob

Post by Hipreme »

Hello guys, I've been adapting my game for Android, for including google AdMob, and there was just too much error, the first thing to understand is that I've been using LOVE for Android for generating my apks.
I'm making this guide for you who've been wanting to publish your game while using AdMob, I'll not release yet my tool for calling admobs inside your .lua file, but this will give you an overview that tutorials made by google won't work when doing this distribution:


So, the first problem you will find when adapting the admob sdk for LOVE, is some strange error that when including this into your build.gradle ->

Code: Select all

    implementation 'com.google.android.gms:play-services-ads:19.2.0'
Apparently, for me, it is returning admob lite(when analyzing into errors from the java stacktrace)
Admob Lite SDK
But that is quite okay, it still works, you can integrate as the main doc from admob.
When integrating new things into your LOVE Android project, there are 2 AndroidManifest.xml that you need to mantain, one stands for the normal assemble and playstore,located on app/src/main the other last is the embed, /app/src/embed(which will probably be the one you will be testing while using Android Studio)

While integrating, there are 2 things that you need to copy over every manifest:
Below <manifest> declaration, include ->

Code: Select all

  <uses-permission android:name="android.permission.INTERNET"/>
Without this, your ad won't run
And the other is below <application> tag:

Code: Select all

<meta-data
        android:name="com.google.android.gms.APPLICATION_ID"
        android:value="ca-app-pub-3940256099942544~3347511713"/>
 
The app id here is from the Google Ad Test, just replace with your own, those 2 things are already documented on the main doc, the problem is when distributing and including that in your application, it will crash for still every build, now, for it to work with the Embed Build
you need to include below your game <activity> tag:

Code: Select all

<activity
          android:name="com.google.android.gms.ads.AdActivity"
          android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
          android:theme="@android:style/Theme.Translucent" />
          
The other problem it will give is that you need to include

Code: Select all

          <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
While it is being documented that this is NOT needed on 17.2 or greater Admob sdk, mine would not work without this piece of code
Without this, my embed build refused to show the Ad, this is undocumented on the main documentation,

For the normal/playstore build, include the following code in their manifests:

Code: Select all

<meta-data
        android:name="com.google.android.gms.ads.AD_MANAGER_APP"
        android:value="true"/>
        
Without this tag, when testing your app, it will probably give the error Unable to get provider com.google.android.gms.ads.MobileAdsInitProvider, and the documented part Google Mobile Ads SDK was initialized incorrectly it is undocumented, so, really, remember to do this, or your app won't work, although in the main documentation Google Mobile Ads SDK was initialized incorrectly means that you haven't put your APPLICATION_ID, without this last piece of code, it would not work
User avatar
AuahDark
Party member
Posts: 107
Joined: Mon Oct 23, 2017 2:34 pm
Location: Indonesia
Contact:

Re: [DISTRIBUTION GUIDE] General problems stumbled when distributing android with AdMob

Post by AuahDark »

You may want to add all of those into the `app/src/main/AndroidManifest.xml` instead of per-individual AndroidManifest.xml in normal/playstore/embed variant.
Profile. Do you encounter crashes in LÖVE Android and wanna send me logcats? Please hit me up in LÖVE Discord and send the full logcat file!
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 7 guests