Does anyone know the most up-to-date way to use AdMob for android please? Since the breaking changes in version 17.0.0 of the SDK you can no longer use the same method James Montemagno uses, and his way is pretty much what is all over the internet.
By that I mean, he initialises ads using the app id in MainActivity.cs
, now it is required to be in the AndroidManifest.xaml
in a <metadata/>
tag.
Also, if anyone knows how to make Native ads and consume them with forms I would love to have a resource or guide I can follow for this. Thanks in advance.
Answers
Before you start, you have to setup an Admob account. Next you need to create an Ad Unit. Then implement the AdView.
Create the AdView control and pass the AdUnitId.
Then achieve on platform projects.
Check the Tutorial:
https://xamarinhelp.com/admob-xamarin-forms-display-google-ads-mobile-app/
@Jarvan Thanks, but like I said. That way does NOT work anymore. Everything you have above is exactly the code I have. And if you look at this StackOverflow post, you will understand more what I am trying to say in this post.
https://stackoverflow.com/questions/52786963/unable-to-get-provider-com-google-android-gms-ads-mobileadsinitprovider-java-la
Check the tutorial:
https://montemagno.com/xamarinforms-google-admob-ads-in-android/
this has nothing to do with the way of using it. as the SO answer said, you just have to add your google admob id into your manifest. thats all done.
@batmaci it has everything to do with it. If you had updated to the most up-to-date android sdk and used the method Jarvan has shared above you will realise you application WILL NOT even run, because you will get the error stated in the stackoverflow post i shared. Either that or there's something else wrong with my application. And if you also look in that post you will see that the chosen answer confirms google has changed the way they handle the ad-mob id.
When I tried that new way i.e. using the
metadata
tag, the program runs but won't show the ad banner. Which is why I am here asking for assistance.Hi, If you are trying to use Admob in your apps, I'd suggest you to install the free plugin MarcTron.Admob.
I've created the plugin and it allows you to add ads in your app in a single line of code.
You can find a tutorial here: https://www.xamarinexpert.it/admob-made-easy/
and the nuget package here: https://www.nuget.org/packages/MarcTron.Admob/1.4.4
@MarcoTroncone thanks i'll check out your plugin!
@iooovolts did you finally get it to work?