[DISTRIBUTION GUIDE] General problems stumbled when distributing android with AdMob
Posted: Thu Jul 02, 2020 6:10 pm
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 ->
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 ->
Without this, your ad won't run
And the other is below <application> tag:
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:
The other problem it will give is that you need to include
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:
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
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'
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"/>
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"/>
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" />
Code: Select all
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
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"/>